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.
Post Reply
podhrmic
Posts: 21
Joined: Wed Nov 06, 2013 1:40 am

STM32 Time capture with channel 3

Post 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)?

icu_with_ch3.zip
(5.83 KiB) Downloaded 639 times
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32 Time capture with channel 3

Post by Giovanni »

Hi,

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

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

Re: STM32 Time capture with channel 3

Post 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.

https://github.com/dsigma/ChibiOS/tree/ ... CAP/timcap

Hope someone finds this helpful...

Best Regards,
-d
Post Reply