Skip to main content
DJ1
Associate III
September 5, 2023
Question

Bare Metal Timer PWM generation using DMA

  • September 5, 2023
  • 11 replies
  • 4284 views

Hi guys, Can anyone list out a few steps which need to be followed for bare-metal code generation of using Timer in DMA for PWM generation. 

Thanks!

This topic has been closed for replies.

11 replies

Associate II
September 5, 2023

Hi,

I am not sure if it will answer your query properly but I think this Timer + DMA + PWM  might help you.

DJ1
DJ1Author
Associate III
September 5, 2023

Hi thanks but i am looking for Bare-Metal approach of code rather than using HAL Libraries. Because in the reference manual there are no clear step for using Timer DMA

Associate II
September 6, 2023

You can always explore the HAL function to know what they are doing that you need to do for bare metal to work.

ST Employee
September 5, 2023

Hello @DJ1 , 

A similar question has been raised and answered by Jan, you may want to check it out here 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
DJ1
DJ1Author
Associate III
September 6, 2023

Hi sarra, thanks but the thing is i am able to generate PWM using timers but not using timer DMA. If you can help me that !

Issamos
Super User
September 6, 2023

Hello @DJ1 

This tutorial (guide + vidéo) is downing exactly what you are looking for.PWM with DMA in STM32.

Best regards.

II

Johi
Senior II
September 6, 2023

I made some examples in LL_ instead of HAL_ is LL_ ok for you or not "Bare metal" enough?

waclawek.jan
Super User
September 6, 2023

What *exactly* do you want to do? Details matter.

On what STM32?

What do you already have?

JW

PS. Maybe have a look at "breathing" demo (table-driven version, as the other one is slightly crazy) here.

DJ1
DJ1Author
Associate III
September 7, 2023

Hi, so the thing is earlier i tried on how to increase the clock frequency using PLL through bare metal coding/scratch. Now i want to use timers for generating PWM using DMA. So what would be the steps to follow for using PWM with DMA that to coding from scratch/using register without using HAL libraries. I went through the HAL_TIM_PWM_Start_DMA function but could not get much through it.

I also tried developing code through registers but in that the PWM is not generating.

LCE
Principal II
September 7, 2023

HAL stuff is hard to read and get through, but (most of) it works.
So you just need lots of concentration and perseverance...

When starting from scratch:
- read the RM
- "collect" relevant registers
- start simple: no settings, just a fixed frequency & duty cycle square
- then add stuff...

PS: DMA is one of the few things I use HAL, many of the HAL_DMA_Start functions are quite "slim" compared to the normal HAL stuff

waclawek.jan
Super User
September 8, 2023

Which STM32?

> I also tried developing code through registers but in that the PWM is not generating.

Show.

JW

PS. +1 to what @LCE  wrote above.