cancel
Showing results for 
Search instead for 
Did you mean: 

I am trying to configure PWM on Nucleo-F334R8 and I am getting PWM on the scope. As per Scope, PWM output is not clean square wave.

RShah.2
Associate II

When Pulse is high, I can see the deviation of 140mv in output voltage instead of clean 3.3V.

Also, I tried different frequencies and Counter Period but no change in waveform.

On inspection it looks like that output pin is ramping down and again going high. and this goes on for entire high pulsewidth.

Kindly let me know how do I clean the PWM output?

Edit:

  1. I used external pullup of 4.7k but because of that I had spikes in negative pulsewidth.
  2. I used Internal Pull Up resistor in push-pull mode but it made the waveform worse.
  3. PWM was configured for around 1.9Khz frequency.
  4. Maximum Output speed was set to Low and High to no change in output.

pics are attached herewith.

7 REPLIES 7

Power supply is clean? What board is this? All ground pins are connected?

JW

  1. I am using just USB as power supply. I am using same usb with other Arduino Board and Waveform is clean in PWM.
  2. Board is Nucleo-F334R8.
  3. I am using board in default condition.

Let me know for any further information.

Edit: I connected the board to Wallmount 5V supply but there was no change in waveform quality.

Which pin is that?

Check the board schematics, is perhaps something else connected to the pin on the board?

Read out and check all relevant GPIO and timer registers values, and/or share them here.

It is PINC0 and it is not connected to any hardware on the board.

The board is Nucleo-F334R8.

PC0 GPIO Mode is set as below :

  1. GPIO mode - "Alternate Function Push Pull"
  2. GPIO Pullup/PullDown - "no pull up pull down"
  3. Maximum output speed - Medium

I tried with "Open drain" and with internal pullup and external pull up. But the result is worse and screenshot is uploaded before.

I also tried with Pullup and Pulldown in "Push Pull" mode but again result is worse.

Timer 1 Configuration:

1. Clock source - Internal Clock

2.Channel 1- Pwm Generation CH1

3. Channel 2 - PWM Generation CH2

4. Prescalar - 8

5. Counter Period - 4095

6. Auto Reload preload - Disable

7. PWM Mode - Mode 1

8. Output Compare Preload - Enable

9. Fast Mode - Enable

I have listed all relevant register configuration, If you need any more information, I would share it with you.

Note: I am using STM32CubeIDE for configuration and programming.

I can't find a single register value in your post.

Laurent Ca...
Lead II

Dear @RShah.2​ 

Do you have still this problem to solve?

And just in case, if not, do not hesitate to share the final solution you found.

Best regards

Laurent Ca...

Laurent Ca...
Lead II

Dear @RShah.2​ 

I guess you don't have to solve this problem anymore, therefore I consider this thread closed.

If not, feel free to reopen it by posting an answer.

Best regards

Laurent Ca...