cancel
Showing results for 
Search instead for 
Did you mean: 

Speed Limit of the ''HAL_GPIO_TogglePin'' ?!!

hesam moshiri
Associate III
Posted on July 06, 2018 at 16:28

The original post was too long to process during our migration. Please click on the attachment to read the original post.
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on July 06, 2018 at 16:44

The interrupt service routine takes too long to execute, that's what limits the 'maximum frequency' here.

This question is reocurring here quite often, e.g.

https://community.st.com/0D50X00009XkW8YSAV

JW

View solution in original post

6 REPLIES 6
Posted on July 06, 2018 at 16:42

Don't generate interrupts at this rate, you'll saturate the processor. The TIM provides ways to toggle or pulse pins into the 10's MHz

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 06, 2018 at 16:44

The interrupt service routine takes too long to execute, that's what limits the 'maximum frequency' here.

This question is reocurring here quite often, e.g.

https://community.st.com/0D50X00009XkW8YSAV

JW

Posted on July 06, 2018 at 17:15

the reason why I'm doing this because I want to generate pulses with a full control over their freq, duty and phase. the PWM can fix two of them but I could not find a satisfactory method to control the phase (in relation to another PWM signal)

Posted on July 06, 2018 at 17:47

Use master-slave arrangement of timers to control phase.

There are also the combined outputs in the newer STM32's timers, e.g. in L4.

If you are desperate, 1MHz interrupt toggling a pin in a 'F4 might be viable, but only if you very well know what are you doing - and using Cube does not really indicate that.

JW

Posted on July 06, 2018 at 17:59

I will try your suggestion but using the Cube should not lead to the slower operation of the timer or GPIO.

Posted on July 06, 2018 at 18:19

Actually I had done this many times in few traditional 8 bit MCUs and so I can not understand why this can not happen here, apart from the fact that pulse generation using interrupt is an efficient method or not.