ICU and timer channel?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: ICU and timer channel?

Post by Giovanni »

I must have missed that part, so no channels 3 and 4 it seems...

About the optimization you proposed, I am all for optimizations so give it a try, but look at code size, often you optimize something and the result is not what you expected.

Giovanni
utzig
Posts: 359
Joined: Sat Jan 07, 2012 6:22 pm
Has thanked: 1 time
Been thanked: 20 times

Re: ICU and timer channel?

Post by utzig »

I know what you mean! :)

Here goes a patch attached with the proposed modifications. In retrospect I would say that it doesn't look that much better! If we had 4 channels and four nested if's than it would really look a lot better.

Anyway, I already tested this modifications and everything works but the patch is entirely optional so you can apply if it suits your tastes!

Regarding that comment from the reference manual cited before, it only exists on the RM0080 (STM32F1xx). The RM0090 (STM32F4xx) doesn't have it, although it clearly supports only TI1FP1 and TI2FP2 as triggers too.
Attachments
icu_add_masks_to_driver.patch.gz
(892 Bytes) Downloaded 475 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: ICU and timer channel?

Post by Giovanni »

The patch looks good but if it does not give a definite advantage better do not integrate it because it uses more RAM and RAM is more valuable than Flash usually.

Giovanni
mobyfab
Posts: 484
Joined: Sat Nov 19, 2011 6:47 pm
Has thanked: 21 times
Been thanked: 31 times

Re: ICU and timer channel?

Post by mobyfab »

The current ICU implementation only supports PWM input mode, right?

What about input capture mode? (to measure a frequency only)

Thanks.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: ICU and timer channel?

Post by Giovanni »

It measures periods already, are you suggesting a different mode?

Giovanni
mobyfab
Posts: 484
Joined: Sat Nov 19, 2011 6:47 pm
Has thanked: 21 times
Been thanked: 31 times

Re: ICU and timer channel?

Post by mobyfab »

My understanding is that its purpose is to support the PWM input mode, therefor the channels 3 and 4 cannot be supported due to hardware limitations on the stm32.

Basically I want to use it to measure frequencies on all 4 channels, I don't care about the pulse width.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: ICU and timer channel?

Post by Giovanni »

A frequency counter would only be possible using two timers, one counter and another to generate the time base unless I am missing something.

It would be possible to use the four comparators to make four period measurements using a single timer but it would a very different driver from the current ICU which is meant for PWM. It would have to be an entirely different driver, you may consider a custom driver, much of the code could be derived from the ICU one.

Giovanni
mobyfab
Posts: 484
Joined: Sat Nov 19, 2011 6:47 pm
Has thanked: 21 times
Been thanked: 31 times

Re: ICU and timer channel?

Post by mobyfab »

Yes I was thinking about using the four comparators. I'm gonna check how ST does that in their FW examples.

Thanks.
kgysmits
Posts: 20
Joined: Tue May 03, 2011 10:16 am

Re: ICU and timer channel?

Post by kgysmits »

Any chance on using the quadrature encoder function through the ICU driver?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: ICU and timer channel?

Post by Giovanni »

Hi,

The ICU driver is meant for PWM input, other uses would require another driver model or custom code using a time at register level.

Giovanni
Post Reply