cancel
Showing results for 
Search instead for 
Did you mean: 

PWM with DMA

hdemi.1
Associate III

4 REPLIES 4
KiptonM
Lead

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.

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

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

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....