cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO toggle in interrupt timer

Pacioc193
Associate II

I'm trying to create a Synchronous communication using a timer and GPIO.

I can toggle a pin-up to 1Mhz inside the main function, but if I try to toggle gpio inside the timer interrupt handler, the max toggle speed is around 300khz. Is there a reason for this behaviour or I'm doing something wrong?

4 REPLIES 4

Doing something wrong..

You can't interrupt at this speed, you saturate the MCU.

Use the TIM itself to toggle one of its TIMx_CHx pins, either in Toggle or PWM Output modes.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pacioc193
Associate II

I've got the same issue with the PWM channel mode... I'm not able to create a PWM faster than 100khz...

I need to create a sort of SPI without having even byte alignment...


_legacyfs_online_stmicro_images_0693W00000bjBPoQAM.png 

The final speed must be 158khz, i need to toggle the data pin before the rising edge of clock.


_legacyfs_online_stmicro_images_0693W00000bjBQNQA2.pngSomething similar to this... using synch serial hardware module, it generate the data not usefull during transmission.

I2C Module hardware protocol coded inside... Any tips?

Use DMA for high speed modulation.

For complex patterns at pins consider using TIM+DMA+GPIO to move pattern buffer to GPIO Bank. Either ODR or BSRR.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Have you got some example snippet from where i can start?