cancel
Showing results for 
Search instead for 
Did you mean: 

[STM32F0] How to generate PWM with DMA

JDooe
Associate II

Hello,

I'm working with CubeMX to configure my MCU (STM32F030CCT6TR) for my school project. I want to generate a PWM with DMA but I don't know how to do it even after doing researches.

Currently I configure my DMA as attached.

Can you help me ?

Best regards,

John

6 REPLIES 6
Khouloud GARSI
Lead II

Hi @JDooe​ ,

I'd highly recommend you to refer to TIM example under the STM32CubeF0 V1.9.0 firmware package. 

It's found under the path below:

STM32Cube_FW_F0_V1.9.0\Projects\STM32F030R8-Nucleo\Examples\TIM\TIM_DMA

The example titled "TIM_DMA" provides a description of how to use DMA with TIMER Update request

to transfer Data from memory to TIMER Capture Compare Register.  The objective of the example is to configure TIM1 channel 3 to generate a complementary PWM signal.

You may take this example as a reference to correctly configure your peripheral.

Khouloud.

JDooe
Associate II

Hi @Khouloud GARSI​ ,

Thank you for your help. I will look this up.

Best regards,

John

You're always welcome!

If you have any further questions, do not hesitate to post them on our STM32MCUs Forum 😉

Best regards,

Khouloud.

JDooe
Associate II

Hello,

I found examples that use TIM DMA but the target wasn't the same as mine. So I tried to understand the code of the main.c and adapt it.

I found the problem. It was from my TIM configuration I didn't initialize the good Channel that I use for my PWM.

Now I can generate a PWM but when I want to change the value of my buffer that i use to generate the PWM, the PWM doesn't change.

Can you help me ? Do you have any idea how to debug the code of the main.c, attached?

Best regards,

John

JDooe
Associate II

Up

$AK
Associate III

Hello @JDooe​ 

I too face the same issue with different mcu, did you find any solutions for the issue stated.

If so kindly reply with it.

Regards,

AK