Pumpkin, Inc.

Pumpkin User Forums

Delay Question

If you have a general question or comment regarding Salvo, post it here.

Delay Question

Postby aek » Tue Apr 02, 2002 4:59 am

Hi Nado.

quote:
After OSTimer() is called in an interrupt, does control return to the scheduler, or does execution resume where it left off?

It resumes where you left off. OSTimer() is very short -- perhaps 20 cycles or so. So, in your original scenario, when OSTimer() is called and the LED update task becomes eligible again, it will not run until the "slow" multiply task is finished and yields back to the scheduler via OS_Yield().

Obviously, an interrupt-driven LED update will have the least jitter, and may also be the smallest solution, ROM-wise. Be sure to code it entirely in the module that contains the interrupt function so that PICC saves only the minimum register set.

If you can tolerate some jitter (I'm assuming you'll be running at 20MHz / 200ns/instruction, since you have a relatively fast timer tick of 2ms), then you could simply add a couple of OS_Yield()s to the multiply task. 2ms @ 20MHz is 10,000 instructions. Even for a slow multiply task, that's a long time. By spacing a couple of OS_Yield()s evenly (instruction-count-wise) in your slow multiply task, then you can do the LED updates from a task and end up with fairly minor jitter.

If you have something like a = b * c * d, you could do:

code:
...
a = b * c;
OS_Yield();
a *= d;
OS_Yield();
...

The idea being that since OS_Yield() is only callable at the C level (not at the assembly / machine instruction level), by splitting the operation into a couple of steps, you can interject OS_Yield()s between PICC library calls (to the multiply routine). Your ROM will only grow (roughly) by the size of an extra OS_Yield() ... not really a big deal. The actual number of cycles spent multiplying won't change much either, though you will have extra trips through the scheduler ... but it's a slow / low priority task anyway ...

All interrupts are of course of higher priority than any task. I'm not sure why you need to update an LED at 500Hz. Assuming that it's a human-interface issue, I would assign the LED update task a moderate priority, so that the system can still have even more important tasks and interrupts at a higher priority than the LED updates.

Just some thoughts ...

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Delay Question

Postby Nado » Tue Apr 02, 2002 12:46 pm

I'm currently drawing up a plan of attack for my project, and have a question. (I've played around with the Lite version, and am currently waiting for purchasing to order the pro version). I'm using a PIC16F876.

After OSTimer() is called in an interrupt, does control return to the scheduler, or does execution resume where it left off?

Here's the situation. I have a low priority task that is going to be doing multiplications/divisions which will eat up lots of cycles. Every 2 ms I need to update a digit on a 5-digit LED. I had originally thought to use a high priority task, delayed 2 ms, for the LED update. But, if control returns to the slow running task after OSTimer() is called, then I could be waiting a while, depending on where I place OS_Yield. In that case, I'd just update the LED in the interrupt routine.

I apologize if this has been answered elsewhere, I wasn't able to find it. Thanks.

Nado
 
Posts: 14
Joined: Tue Apr 02, 2002 12:00 am
Location: Westlake, OH, USA

Re: Delay Question

Postby Nado » Wed Apr 03, 2002 6:02 am

The entire refresh rate for the display is actually 100 Hz - each digit of the 5 segment display is updated every 2 ms, or 10 ms total. Right now it's the only interaction between human and machine, but they're looking to do more in the future.

Thanks again for your help. I'm sure I'll have more questions once I start coding.

Nado
 
Posts: 14
Joined: Tue Apr 02, 2002 12:00 am
Location: Westlake, OH, USA

Re: Delay Question

Postby tbims23822 » Tue Jul 07, 2009 7:21 am

www.drop-shopping.com is a premium website for cheap air jordans shoes and other more really nike air jordan shoes.We have varity of cheap air jordan shoes available for wholesale.Cheap China wholesale shoes including cheap Nike shoes and cheap jordan shoes,nike sneakers,nike sneakers discount,air jordan sneakers,air force sneakers.We supply nike sneakers,jordan sneakers,air jordan sneakers,air force sneakers wholesale.You can buy very cheap jordans shoes including cheap women shoes,cheap nike shoes,cheap running shoes from us.
tbims23822
 

Re: Delay Question

Postby tbims23822 » Tue Jul 07, 2009 8:27 am

www.drop-shopping.com is a premium website for cheap air jordans shoes and other more really nike air jordan shoes.We have varity of cheap air jordan shoes available for wholesale.Cheap China wholesale shoes including cheap Nike shoes and cheap jordan shoes,nike sneakers,nike sneakers discount,air jordan sneakers,air force sneakers.We supply nike sneakers,jordan sneakers,air jordan sneakers,air force sneakers wholesale.You can buy very cheap jordans shoes including cheap women shoes,cheap nike shoes,cheap running shoes from us.
tbims23822
 

Re: Delay Question

Postby tbims23822 » Tue Jul 07, 2009 8:34 am

www.drop-shopping.com is a premium website for cheap air jordans shoes and other more really nike air jordan shoes.We have varity of cheap air jordan shoes available for wholesale.Cheap China wholesale shoes including cheap Nike shoes and cheap jordan shoes,nike sneakers,nike sneakers discount,air jordan sneakers,air force sneakers.We supply nike sneakers,jordan sneakers,air jordan sneakers,air force sneakers wholesale.You can buy very cheap jordans shoes including cheap women shoes,cheap nike shoes,cheap running shoes from us.
quote:
Originally posted by Nado:
The entire refresh rate for the display is actually 100 Hz - each digit of the 5 segment display is updated every 2 ms, or 10 ms total. Right now it's the only interaction between human and machine, but they're looking to do more in the future.

Thanks again for your help. I'm sure I'll have more questions once I start coding.


tbims23822
 


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron