Hi,
I created a new task using OSTaskCreate and everything works fine. I would however like to limit the frequency at which the new task runs. I want to limit it to 50 Hz, I was using PIT1 as free running timer configured for 50 Hz and I was checking the interrupt flag to see when the timer count is complete. Is there any other way I can do it more efficiently?
Thank you,
TM
Running a OS new Task at specific frequency
Re: Running a OS new Task at specific frequency
A Real Time OS is different than a time slice OS. The highest priority task ready to run will always run. One possibility would be that you could make it a very high priority, add a blocking function like a semaphore, than post the semaphore at your frequency. However, this seems like an architecture issue that should be addressed in a different way.
-
- Posts: 513
- Joined: Sat Apr 26, 2008 7:14 am
Re: Running a OS new Task at specific frequency
If the task really needs to run at 50Hz, use a timer (PIT, DMA, or on some platforms, the GPT timer) to generate an interrupt that calls an ISR every 20mSec that, in turn (as rnixon suggests) posts a semaphore to a hi priority task (low task prio number). Depending on what you want to do, an IRQ may not be required. For example if all you want to do is to set, clear, or toggle one of the timer-related pin levels, just init the timer once in output compare mode and let the hardware do its job. Of course, your task may be more complicated, or you may not want the action (eg your task) to occur at 50Hz rate....
Re: Running a OS new Task at specific frequency
I had it setup as a separate ISR but I have several interrupts running and they are interfering with each other leading to noisy data. This made me run the most important task as a separate OS task. When I checked with oscilloscope the new task frequency was approximately 1.4 KHz. Everything works fine but I want to reduce the frequency to do some test. Anyways thanks for the suggestions and I don't see any harm in trying it out.
Thanks,
TM
Thanks,
TM
Re: Running a OS new Task at specific frequency
You could just put an OSTimeDly(x) in the task loop to slow it down for testing. It would not be deterministic, but for 50Hz from 1.4 Khz, it would be pretty good. You could also use the HiResTimer functionality to get very close to 50 Hz.
Re: Running a OS new Task at specific frequency
I set up a PIT timer and in that ISR post to a semaphore....
I have some code that does this cleanly... what platform are you running on?
Paul
I have some code that does this cleanly... what platform are you running on?
Paul
Re: Running a OS new Task at specific frequency
Looking at his previous posts, it appears he's using a MOD54415.
Dan Ciliske
Project Engineer
Netburner, Inc
Project Engineer
Netburner, Inc