cancel
Showing results for 
Search instead for 
Did you mean: 

Using Input captur in PWM mode with DMA

I2.1
Associate II

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

5 REPLIES 5
Issamos
Lead II

Hello @I2.1 

This tutorial is doing exactly what you are looking for.

Best regards.

II

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

Issamos
Lead II

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

Sarra.S
ST Employee

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.

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