cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0 Variable square wave generation

ECast.12
Associate II

Hi all, I'm using a NUCLEO-G071RB board and I simply want to generate a variable frequency square wave. I started from project TIM_OCToggle found on the examples.

My problem is that TIM1 channel 1 has a fixed frequency and even if I change it through the sConfigOC struct with HAL functions, and I see changes in htim1->Instance registers after my function SetOutputFrequency(), nothing seems to happen on the ouput PA8, I see only some periods ON or OFF with the oscilloscope. Where are my errors? Is there a simple way to do what I need without using HAL libraries (portability and readability doesn't walk together...) ? Thanks in advance, Emanuele.

12 REPLIES 12

Many thanks MM..1, not it works. I didn't see HAL_TIM_OC_DelayElapsedCallback() function inside main.c. that is the clear solution.

Sorry for my mistake and thanks again for your time. Emanuele.

Now it works...

Perfecto and you can edit posts... 😉