Sterling
Sterling
DIIDevHeads IoT Integration Server
Created by Sterling on 7/24/2024 in #firmware-and-baremetal
Why Do I Need to Halve Prescaler Values for TIMER 2 & 3 on STM32F4 to Get Correct Interrupt Periods?
Good day everyone, @Middleware & OS I'm using an STM32F4 with three timers and experiencing unexpected behavior with the timers' interrupts. - TIMER 1 (advanced control) generates an interrupt every 1ms with (\text{PSC} = 11) and (\text{ARR} = 13999) as expected. - TIMER 2 (general purpose) is supposed to generate an interrupt every 10ms. Calculations give (\text{PSC} = 39) and (\text{ARR} = 41999), but the interrupt occurs every 20ms. To achieve 10ms, I had to set (\text{PSC} = 19). - TIMER 3 (general purpose) should generate an interrupt every 65.535ms. Calculations give (\text{PSC} = 167) and (\text{ARR} = 65535), but the interrupt occurs every 131.064ms. Halving the PSC to 83 gives the correct 65.535ms period. Oscilloscope outputs: - TIMER 3 with (\text{ARR} = 0xFFFF) and (\text{PSC} = 167): output is NOT as expected. - TIMER 3 with (\text{ARR} = 0xFFFF) and (\text{PSC} = 83): output is as expected. Why do I need to halve the prescaler values for TIMER 2 and TIMER 3 to get the correct interrupt periods?
7 replies