2013-04-22 02:40 AM
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. Jin2013-04-22 04:22 AM
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.