cancel
Showing results for 
Search instead for 
Did you mean: 

Servo buzzing and not working with STM32G030C8T6

MaciejG
Associate II

Hi, I encountered a problem while trying to control servo motor(SG90) with my custom STM32G030C8T6 board. Servo is not moving at all and only buzzing quietly. I am supplying servo from 5V, board and servo have same GND. I checked servo power supply with potentiometer and voltage seems good. I designed power supply to be able to work with 3A so it should not be a problem either. At first I thought there was a problem with frequency of generated PWM signal (servo is working with 50Hz) but I cannot see any mistake in calculations. APB freq is set to 16MHz. I've tried many combinations of prescaler and ARR values (16-1 prescaler and 20000-1 ARR for example) none of it worked. I have tried with other servos and every try failed. I would be very grateful if someone has any ideas how to deal with this problem. 

MaciejG_0-1701631594463.pngMaciejG_1-1701631675575.pngMaciejG_2-1701631725500.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
MaciejG
Associate II

Hi I know where the problem came from. I used too long wires for connecting power supply to my board and after shortening it everything seems to work properly.

View solution in original post

4 REPLIES 4
TDK
Guru

Math seems okay. Can you view it on a scope or logic analyzer? It could be that the polarity is wrong. Try it with a compare value of 19000/18500.

If you feel a post has answered your question, please click "Accept as Solution".

Get a scope on it

Print out the CPU/AHB/APB clocks that it think's it's running from it's perspective.

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

I have tried values 18500/19000 to check if there is reversed polarity but it didnt work. Also tried to watch outputs from HAL_RCC_GetSysClockFreq(), HAL_RCC_GetHCLKFreq() and HAL_RCC_GetPCLK1Freq() functions via live expressions watching in debugger and values seems to be ok. I found topic on other chat that in my STM32 model problem with timers 16 and 17 have been found but changed to tim3 and problem still occurs. Tomorrow I will use scope and update topic. 

MaciejG
Associate II

Hi I know where the problem came from. I used too long wires for connecting power supply to my board and after shortening it everything seems to work properly.