2021-02-05 12:40 AM
I am working with the STM32F769 microcontroller and it's using the FreeRTOS realtime operating system and TIM6 is chosen to generate TICK interrupts and my desired RTOS TICK rate is 1 kHz. The SystemCoreClock is 216 MHz, which means none of the hardware timers (TIM1 - TIM14) can be prescaled down to 1 kHz. I believe it's ST32CubeMX that then has decided that TIM6 should generate interrupts every 1 microsecond, i.e. at 1 MHz (!!!), which seems incredibly fast if we want 1 kHz "in the end" (RTOS TICK frequency). What are the least amount of changes I need to do to make TIM6 generate interrupts at 2 or 4 kHz instead of 1 MHz and still ensure that the RTOS TICK frequency remains at 1 kHz? I tried to follow TIM6_DAC_IRQHandler and that took me to HAL_TIM_PeriodElapsedCallback and that calls HAL_IncTick, but all that function does is incrementing uwTick += uwTickFreq so I wasn't able to actually find the function inside the RTOS that actually gets called every 1 ms (1 kHz).
2021-02-05 05:40 AM
The TIM6->CNT increments every microseconds, but it won't trigger an interrupt until TIM6->CNT reaches 1000. Thus, TIM6_DAC_IRQHandler will be called every 1 ms, not every 1 microsecond.
2021-02-05 05:57 AM
Just FYI - TIM6 is the timebase for the HAL, not for FreeRTOS. SysTick is the timebase for FreeRTOS.