cancel
Showing results for 
Search instead for 
Did you mean: 

stm32l152 Timer problem

xinjin
Associate II
Posted on April 22, 2013 at 11:40

Hello,

        I modify the demo code in STM32L1xx_StdPeriph_Lib_V1.2.0 --> TIM --> OCToggle. I reconfigured the TIM3_CH3 CCR3_Val to 40 to generate 200KHz square waveform. The output frequency measured is only 122Hz. But while I change TIM3_CH3 CCR_Val to 400, it can generate 20KHz square waveform. Could you help find what the rootcause would be?

Thanks.

B.R.

Jin
1 REPLY 1
Posted on April 22, 2013 at 13:22

Without looking at the example, I don't have it to hand, it is likely that the rate of the interrupt exceeds the saturating point of the processor.

For high rates (>several hundred KHz) you want the HARDWARE to do the work, which would mean using the PERIOD value and one of the output modes. PMW modes with PERIOD/PULSE configuration being particularly effective. You will be limited to one frequency per timer, but could get different dutys for different channels.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..