cancel
Showing results for 
Search instead for 
Did you mean: 

Timer triggered DMA to GPIO for soft PWM

damanuel
Associate II

I'm trying to to generate a PWM signal on a GPIO without PWM capability on a STM32F47. To achieve this, I want to have a timer triggered DMA transfer to the GPIO BSRR register.

Looking at the bus matrix, it seems that I need to use the DMA2 controller to transfer memory to the GPIO registers, because the GPIOs are on the AHB1 bus. Is this correct?

If I want to use the DMA2 controller, I guess I need to look at the streams in the DMA2 request mapping. From there it seems that I can only use TIM1 and TIM8 to trigger DMA transfers to the GPIO peripherals. Is this correct - or do I have more flexibility?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Yes and yes, you are limited to TIM1/8. Other timers are on a different bus.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

6 REPLIES 6
TDK
Guru

Yes and yes, you are limited to TIM1/8. Other timers are on a different bus.

If you feel a post has answered your question, please click "Accept as Solution".
damanuel
Associate II

Thanks, I managed eventually. This was one of the pitfalls I fell into, the other one was having the memory address in the CCM memory instead of SRAM1/SRAM2.

Another question (or should I open another ticket?): I have the timer in upcounting mode and trigger a DMA request and use a circular buffer as source memory which "encodes" the duty cycle. Could I also trigger DMA with the timer in PWM mode? I would need to transfer data to the BSRR on the counter overflow and on the capture/compare. Would I need to set up two DMA streams, one for the TIM8_UP and one for TIM8_CHX?

> I would need to transfer data to the BSRR on the counter overflow and on the capture/compare. Would I need to set up two DMA streams, one for the TIM8_UP and one for TIM8_CHX?

Yes. But why?

JW

Because the pin I want to use can't be PWM'ed, so I need softPWM. And setting up the Timer as PWM and trigger a DMA transfer for high and low makes more sense to me than running over a circular buffer.

That makes sense.

Which pin, exactly?

JW

PE8. Which I am aware that it can be used as TIM1_CH1N. But the problem is that TIM1 is already used to generate another PWM, so I can't use the TIM1_CH1N alternate function on PE8.