cancel
Showing results for 
Search instead for 
Did you mean: 

STM32GO controller PWM Generation issue

Denial1
Associate II
Hello All
Current Device setup:-
NUCLEO-G071RB Eval board
STM32CubeMX settings please find the attached screenshots.
  • I'm trying to generate PWM signal using [ TIM3 channel 3] in NUCLEO-G071RB Eval board.
  • Time period is 28 microseconds and width are 3 microseconds.
  • As you can see in the below [image 1 ]only the first pulse is different or corrupted, which gives 32 microseconds time period and width are 7 microseconds .
  • From the second pulse , we are able to get the expected pulse as shown below [image 2] Time period is 28 microseconds and width are 3 microseconds.
  • Same behaviour is observed in STM32Cube_FW_G0_V1.6.0 package code, given by STM32 Timer PWM output example code.
Please provide the solution to resolve this issue.
 
Image 1:-
Denial1_0-1697024584663.png
 
Image 2:-
Denial1_1-1697024584665.png

 

9 REPLIES 9
Sarra.S
ST Employee

Hello @Denial1

Are you overwriting the CCR register directly? Have you seen this behavior after changing the pulse width from 7us to 3us?

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

TDK
Guru

Probably the first pulse starts before the timer is started.

A solution would be to set the CNT of the timer to a value which produces a low state on the pin, rather than a high state. Perhaps set to ARR-1 instead of 0 during initialization. Or otherwise ensure the output state is low during initialization.

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

Hi @Sarra.S 

I'm using HAL library function to start the PWM

HAL_TIM_PWM_Start_IT(&htim3);  and

HAL_TIM_PWM_Stop_IT(&htim3) to stop the PWM.

Hi @TDK 

I have attached screenshots of STM32cubemx settings. Please look into this.

Hello again @Denial1

I am afraid I couldn't reproduce the issue using the example of the STM32Cube_FW_G0_V1.6.0 package. 

So, could you please specify the sequence to reproduce it; have you changed the PSC register value? I am thinking that during the first timer period timer works with another PSC from previous configuration

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi @Sarra.S 

Thanks for your response!!!!

Path for the example code: -

STM32Cube_FW_G0_V1.6.0\Projects\NUCLEO-G071RB\Examples\TIM\TIM_PWMOutput

I have not changed anything in this example code.

The output can be observed, as shown in the below image 1.

Pin No PA8, PA9, PA10 and PA11 all are having corrupted/ different pulse width of first pulse.

Denial1_0-1697613598275.png

You can easily reproduce this issue, without making any changes to example code.

Looking for your reply!!

Regards,

Denial

Hello again @Denial1

Actually, that's exactly what I did, using the same example with the same FW version with NUCLEO-G071RB.

SarraS_0-1697619485268.png

As you can see, there is no first corrupted pulse.

PS: you mentioned "NUCLEO-G071RB Eval board", is that a typo or are you using a custom board? 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

@Sarra.S,

From the waveform capture it's not clear whether the leftmost pulse was the first one after reset (and I am afraid it wasn't).

@Denial1,

CubeMX with Cube/HAL provides a quick clicking solution to generate PWM but perhaps does not pay much attention to details like this. If you want anything outside of what the Cube/HAL authors deem usual usage, Cube gets into way more than helps. TDK gave you above the explanation for your problem and also a suggested remedy, just follow his recommendation.

JW

@Denial1 I apologize for the previous mistake. You're right @waclawek.jan!

I am tracking this issue with an internal ticket (Ticket 164283), I will keep you informed! 

Sorry for the inconvenience.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.