Electronic – Multiple-channel PWM input on STM32

microcontrollerpwmstm32timer

I am using an STM32F405 based board (OpenPilot revo) to receive PWM signals from a joystick receiver.

I have to capture five PWM signals using only two timers, timer 8 and timer 12. I've already succeeded capturing a PWM signal and computing the duty cycle on only a channel for each timer using the example provided with the standard library (PWM INPUT).

But I couldn't use multiple channels for each timer. How do I configure the channels? It would be great if someone has an example with more than a channel used for PWM input.

Best Answer

Instead of using two capture units to capture rising and falling edges separately, use a capture unit to react to both edges of the signal(s) and determine the state inside the interrupt handler. Or use an external interrupt (pin-change) to react to either signal change and use a free-running timer to capture the counter value in software. If there is a lack of interrupts, you could OR (diodes) the signals to one interrupt input and check the source with regular inputs (one for each signal).