2017-06-16 01:43 PM
Hi
basically I am using freertos in my project and I need a highest prio timer interrupt driven task which needs to be executed in a granularity of 100 ns. (every n* 100 nsec like 100ns, 1500ns,....)
In Cube MX I sat up a timer interrupt(TIM5), but cube will not allow me to have an interrupt lower than level 5. CUBE MX comes with a warrning:
''''preemption priotity of interrupts should be >=5 if their handlers call system functions. see FREERTOS LIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY parameter''''
So how can I have a timer interrupt with this granularity when using freertos?
#timer-interrupt #stm32-freertos2017-06-16 02:46 PM
What's the actual interrupt rate, you're unlikely to be able to sustain something over a few hundred KHz.
If you need to latch something on a 10 MHz clock, consider DMA
2017-06-17 02:54 AM
the interruprate is 10 khz. Actually the interrupt is used to trigger dma
2017-06-17 08:21 AM
Edge placement is going to work a lot better in hardware.
If you have TIM2 (32-bit on several STM32) in maximal mode, clocking at 10 MHz, you can use the channel compare to place an interrupt or DMA trigger along the timeline.
Yes, I'd likely keep the interrupt out of the scope of the full RTOS, to reduce the latency, but you'd have to tread carefully as to what functions you could call, or events you could precipitate.
2017-06-17 02:43 PM
thanks for the info about tim2. The problem is I need to do more than just starting a dma. Still the question remains how can I have a timer interrupt which has a higher prio than freertos?
Or actually could I also setup a freertos thread with prio realtime and use vTaskDelay?
In this case how many cycles is needed for a freertos context switch?
2017-06-17 03:40 PM
As Long as your irq handler doesn't call RTOS functions, there is no restrictions on preemption priority.
In your Cube-Project go to Configuration -> NVIC Configuration -> Uncheck Use FreeRTOS functions at the line of tim2 irq.2017-06-17 05:31 PM
Not using FreeRTOS, can't speculate.
At the end of the day you control the NVIC, both the priority grouping and priority/preemption levels, have your IRQHandler *NOT* call into the RTOS task management and you'll be at 12 cycles in, 12 cycles out.