Skip to main content
I2.1
Associate
September 14, 2023
Question

Using Input captur in PWM mode with DMA

  • September 14, 2023
  • 4 replies
  • 3765 views

Hello, 

I want to capture the duty cycle of an input PWM with the timer feature PWM Input on CH1.

Channel 1 is configured on rising edge, channel 2 is configured on falling edge.

The DMA is configured for this timer on channel 1, channel 2 can't have DMA.

To compute the duty cycle, I need the total period widh (store in CCR1) and the pulse width (stored in CCR2). 

My goal is to start a measurement, and when the DMA is complete, get several values in order to compute an average duty cycle.

Is it possible to get both values (multiple times) with only one channel configured with a DMA. 

 

Thanks

This topic has been closed for replies.

4 replies

Issamos
Lead III
September 14, 2023

Hello @I2.1 

This tutorial is doing exactly what you are looking for.

Best regards.

II

I2.1
I2.1Author
Associate
September 14, 2023

It's almost what I want, but my timer has only DMA for channel 1

Issamos
Lead III
September 14, 2023

I'm not sure. But I think you can do this by setting the polarity selection for both edges (rising and falling edge).

Try this. It may works.

Best regards.

II

ST Employee
September 18, 2023

Hello @I2.1

No, I'm afraid you can't 

As far as I know, it is not possible to configure this DMA channel to transfer data from two different memory locations.

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.
waclawek.jan
Super User
September 18, 2023

Which STM32? Which timer?

You may be able to use the DMAR/DCR mechanism, read description of these registers in TIM chapter of RM.

JW