2019-12-23 01:04 PM
Hi ! Im generating pwm at 200khz with no problems. But when I use timer to generate interrupt I get max 100khz of pulse on pin. No matter if I use HAL_GPIO_Toggle/WritePin or just GPIOx->BSRR. No matter how low value of timer prescaller I use.
Output pin set to high speed. push pull. No pullup, no pulldown.
Why? Software or hardware limitations?
STM32f103c8 at 72 MHz of timer clock.
Solved! Go to Solution.
2019-12-23 06:30 PM
Would probably want to have the TIM trigger the ADC(s) directly. At higher speeds want the DMA to collect the ADC data. You could then toggle at DMA HT/TC interrupts at a slower rate, but could relate edge of that to TIM pin output.
2019-12-23 01:34 PM
Why not describe what you want to achieve?
Are you trying to generate PWM by just timer interrupt? (both rise and fall edge? = 400 kHz interrupt if 50% duty cycle)?
2019-12-23 01:58 PM
You're going to run out of bandwidth. The interrupt has to push/pop context, and the flash memory is fairly slow. You're likely to saturate the processor as you interrupt above 100 KHz
For driving/modulating pulses at high speeds, use the TIM features, and DMA
2019-12-23 05:24 PM
Thanks for answers :)
I wanted to generate a pulse to debug with scope.
PWM_IT 200khz, generates interrupt (both rising and falling edge) that starts ADC and sets some output pin at the same time, when ADC is ready the pin is reset by ADC interrupt.
Wanted to have a visual interpretation of adc conversion time.
2019-12-23 06:30 PM
Would probably want to have the TIM trigger the ADC(s) directly. At higher speeds want the DMA to collect the ADC data. You could then toggle at DMA HT/TC interrupts at a slower rate, but could relate edge of that to TIM pin output.
2019-12-24 01:05 AM
Thanks. I will try to use DMA. But while I wanted to collect an array of 20 samples at high pulse and 20 at low, and then replace first sample in array with another, than second etc. And avarage it. To get "walking" avarage. I think it will be more complicated than I think :)
Or mabey take 20 samples, avarage it, take next 20 samples, avarage, and avarage this two avarages .... ohhh