STM32 Time capture with channel 3

This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general. This forum is NOT for support.
Posts: 21
Joined: Wed Nov 06, 2013 1:40 am

STM32 Time capture with channel 3

Postby podhrmic » Sat Nov 09, 2013 6:55 am

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

User avatar
Site Admin
Posts: 13118
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 767 times
Been thanked: 651 times

Re: STM32 Time capture with channel 3

Postby Giovanni » Sat Nov 09, 2013 9:41 am


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().


Posts: 13
Joined: Sat Jan 26, 2013 12:18 am

Re: STM32 Time capture with channel 3

Postby dsigma » Tue Feb 25, 2014 11:56 pm

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,

Return to “User Projects”

Who is online

Users browsing this forum: No registered users and 3 guests