This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Sinusoidal PWM

Hello,

I'm tyring to program a STM32F4 (with ARM F4) board to generate a sinusoidal PWM, that is a sequence of pulses with variable width that, once filtered by a LPF, gives a sinusoid.

I was told the best way to get it is by generating a sequence of single pulses synchronized to timer by interrupts.

I've tried several solutions but I'm not good at managing interrupts.

Do you have any idea how to achieve this goal?
Can you attach a piece of code where it's explained how to do it?

Thanks in advance! ;)

Mara

Parents
  • It looks like you have a STM32F401RE-Nucleo board. You can download at:

    www.st.com/.../PF259243

    at the bottom of the page is a read button. It provides a few projects for your board as well as other STMF4 Boards. The more expensive boards have the most project examples. I am looking at a Nucleo board the STM32F153RE. It has one project called TIM_DMA which creates a output PWM signal that varies its pulses since the DMA continuously writes to TIM1 Capture Compare Register 3.

    Description in readme file This example provides a description of how to use DMA with TIM1 Update request to transfer Data from memory to TIM1 Capture Compare Register 3 (CCR3).

    The following configuration values are used in this example:

    - TIM1CLK = SystemCoreClock - Counter repetition = 3 - Prescaler = 0 - TIM1 counter clock = SystemCoreClock - SystemCoreClock is set to 64 MHz for STM32F1xx

    The objective is to configure TIM1 channel 3 to generate complementary PWM (Pulse Width Modulation) signal with a frequency equal to 17.57 KHz, and a variable duty cycle that is changed by the DMA after a specific number of Update DMA request.

    The number of this repetitive requests is defined by the TIM1 Repetition counter, each 4 Update Requests, the TIM1 Channel 3 Duty Cycle changes to the next new value defined by the aCCValue_Buffer.

    The PWM waveform can be displayed using an oscilloscope.

    The examples provided for the STM32F401RE-Nucleo do not include a PWM project. But if you
    download the STM32F4 Cube software there are also examples for the Other STM32F4 boards included. You can browse the other projects and take a look at PWM examples. Especially look at the EVAL board projects.

Reply
  • It looks like you have a STM32F401RE-Nucleo board. You can download at:

    www.st.com/.../PF259243

    at the bottom of the page is a read button. It provides a few projects for your board as well as other STMF4 Boards. The more expensive boards have the most project examples. I am looking at a Nucleo board the STM32F153RE. It has one project called TIM_DMA which creates a output PWM signal that varies its pulses since the DMA continuously writes to TIM1 Capture Compare Register 3.

    Description in readme file This example provides a description of how to use DMA with TIM1 Update request to transfer Data from memory to TIM1 Capture Compare Register 3 (CCR3).

    The following configuration values are used in this example:

    - TIM1CLK = SystemCoreClock - Counter repetition = 3 - Prescaler = 0 - TIM1 counter clock = SystemCoreClock - SystemCoreClock is set to 64 MHz for STM32F1xx

    The objective is to configure TIM1 channel 3 to generate complementary PWM (Pulse Width Modulation) signal with a frequency equal to 17.57 KHz, and a variable duty cycle that is changed by the DMA after a specific number of Update DMA request.

    The number of this repetitive requests is defined by the TIM1 Repetition counter, each 4 Update Requests, the TIM1 Channel 3 Duty Cycle changes to the next new value defined by the aCCValue_Buffer.

    The PWM waveform can be displayed using an oscilloscope.

    The examples provided for the STM32F401RE-Nucleo do not include a PWM project. But if you
    download the STM32F4 Cube software there are also examples for the Other STM32F4 boards included. You can browse the other projects and take a look at PWM examples. Especially look at the EVAL board projects.

Children