Page 1 of 1

STM32 Time capture with channel 3

Posted: Sat Nov 09, 2013 6:55 am
by podhrmic
Hi all,

for my project with STM32F105 chip I needed input capture to measure CPPM stream from radio on channel 3 of one of the general purpose timers.
ICU driver is meant to measure duty cycle and period of PWM signal, and according to the datasheet only first two channels can be used for this (look for Filtered Timer Input 1/2). However, I wanted to reuse the ICU code and just allow it to have the third channel.

Here is the code. Just channel 3 for now, channel 4 would be very similar.

I think it is a question mainly for Giovanni - is it ok to have the driver with different functionality for different channels? I.e. PWM measure (CH1 and CH2) vs input capture only (CH3 and CH4)?
(5.83 KiB) Downloaded 182 times

Re: STM32 Time capture with channel 3

Posted: Sat Nov 09, 2013 9:41 am
by Giovanni

The driver model supports PWM-input only, the use of the other comparators could be eventually added as an STM32-specific extension into the low level driver.

In the general architecture such extensions have to be marker using the plarform name, for example you may add a function icuSTM32SetComparator().


Re: STM32 Time capture with channel 3

Posted: Tue Feb 25, 2014 11:56 pm
by dsigma
I ran into the same limitation, but had a more complicated set of requirements. I've implemented a TIMCAP driver that can handle captures for all 4 channels (or 2 channels for timers that only support 2 channels), and call respective callbacks when each of the respective channels does a capture. You can find the driver code and respective demonstration at the link below. I've tested this on an STM32F407. ... CAP/timcap

Hope someone finds this helpful...

Best Regards,