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.
podhrmic
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)?

icu_with_ch3.zip
(5.83 KiB) Downloaded 308 times

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: STM32 Time capture with channel 3

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

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

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.

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

Hope someone finds this helpful...

Best Regards,
-d


Return to “User Projects”

Who is online

Users browsing this forum: No registered users and 2 guests