How to set a Timer > 1000Hz

cpkwok wrote on Monday, December 22, 2008:

I am developing a project on at91sam7se. I set a timer of 10k Hz. However, I found that the timer interrrupt can only be toggled every 1 ms when I set the timer frequency >1000Hz. Is this the limit of the system?

Does anyone have any idea?


rtel wrote on Monday, December 22, 2008:

If you are talking about the tick interrupt, then the SAM7 uses the PIT (Periodic Interval Timer) to generate the tick.  I’m sure you would be able to make it go very quickly, but you might need to change the implementation of prvSetupTimerInterrupt() in port.c to do this (it might be that you need to use some pre-scales or something on the timer).

Also, the standard demos make a lot of use of the constant portTICK_RATE_MS.  If you go above 1ms tick then this will not work.  You don’t need to use the constant, its just for convenience.

Its best to keep the tick interrupt frequency as low as possible, otherwise you could get into to efficiency issues.  If you need a faster timer consider using one of the other timer peripherals in addition to the tick interrupt, then keep the tick frequency lower.


cpkwok wrote on Tuesday, December 23, 2008:

Thx Richard,

Yes, I notice the system tick is using PIT.

I am using Timer0 to generate the 10kHz, But it’s strange that the ISR is called at a limit of 1kHz. I don’t see this problem in another module, say UART. Using the same code, I can do it in a stand alone applcation. Thus I am wondering if there are any missing part that I have to change to do so in FreeRTOS.