cancel
Showing results for 
Search instead for 
Did you mean: 

Hello. When I use external crystals, I have a low frequency (2Hz) disturbance on PWM outputs. This disturbance also appear on SWDIO & SWCLK pins. But everything is ok with internal oscillator. The MCU is STM32f401RBT6. Thank you for your help.

MPenc.1
Associate II

0693W000006EkBvQAK.jpg0693W000006EkBlQAK.jpgThe first image is PWM output when using internal oscillator & The second image is PWM output when using external crystal.

9 REPLIES 9
TDK
Guru

Probably your clock source is getting disrupted. Pipe MCO to an output pin and measure that on the scope along with your PWM signal.

Could also be your chip is getting reset at regular intervals, or timer is getting disabled.

As for why? Hard to say without seeing more information. You can read this for proper selection/wiring of crystals:

https://www.st.com/resource/en/application_note/cd00221665-oscillator-design-guide-for-stm8afals-stm32-mcus-and-mpus-stmicroelectronics.pdf

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

0693W000006EkyTQAS.jpgThank you for your help. The MCO output is OK.

This image is MCU output.

I also found that the frequency of the disturbance varies with PWM frequency.

For example the frequency of the disturbance is 2 Hz when PWM output frequency is 15000 Hz &

the frequency of the disturbance is 0.5 Hz when PWM output frequency is 3750Hz.

TDK
Guru

The timer peripheral isn't likely to contain a glaring hardware error which would cause this. The STM32F4 family is very mature. I would look at your code to see what might be causing this to happen. Perhaps in an ISR routine affected by the frequency of this particular timer somewhere.

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

Yes, Of course.

Here you are.

The code is very simple and we don't have any ISR routines. We just have a PWM signal with frequency = 15KHz & Duty cycle = 50%.

0693W000006EmPfQAK.png0693W000006EmPaQAK.png0693W000006EmPQQA0.png0693W000006EmPLQA0.png0693W000006EmPGQA0.png0693W000006EmPBQA0.png0693W000006EmOwQAK.png

Try to switch off CSS.

JW

MPenc.1
Associate II

Thank you for your attention. I tried that. Nothing was changed.

Try your code on a "known good" hardware such as Nucleo or Disco board.

JW

MPenc.1
Associate II

Thanks. I did it. The disturbance was not removed.

I found that when we remove deadtime, The disturbance is removed.

But I need deadtime.

MPenc.1
Associate II

Hello. I found that when the PWM period is an integer multiple of the dead time, The disturbance is removed.

Do you know why this happens?

Do you know anything about this fact?

Thank you so much.