Skip to main content
hdemi.1
Associate III
January 20, 2023
Question

PWM with DMA

  • January 20, 2023
  • 3 replies
  • 959 views

This topic has been closed for replies.

3 replies

KiptonM
Senior III
January 20, 2023

I do not know about your code, but something else is wrong based on the oscilloscope view.

When the PWM is not happening the sine wave looks good.

When the PWM is working the sine is not as high. Which is what I would expect from PWM, reducing the amplitude based on the percentage on when compared to the time of the off and on cycle.

It looks like you are starting with a sine wave and trying to modify it.

Normally someone starts with a constant voltage and uses PWM to make it look like a sine wave with a non-zero crossing.

KiptonM
Senior III
January 20, 2023

Let me take a wild guess. The sine wave is 60 Hz? Or 50 Hz in Europe?

And you did not ground the probe it is floating?

Or the line is floating? If the line is floating, put a 100K to 1M resistor to ground on the circuit connected to the blue probe.

gbm
Lead III
January 21, 2023

You should do do 16-bit to 16-bit transfers - set memory data size to 16 b and prepare 16-bit data in memory.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
S.Ma
Principal
January 22, 2023

The lack of precising which STM32 we are talking about, answers maybe a miss.

Use a table cyclic looped by the DMA which feeds the Timer output compare.

This way, you can test the output waveform with zero interrupt, if your STM32 can do this.

Otherwise, if there is a DAC on the chip....