Page 4 of 6

Re: ICU and timer channel?

Posted: Thu Mar 15, 2012 3:32 pm
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

Re: ICU and timer channel?

Posted: Thu Mar 15, 2012 5:21 pm
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.

Re: ICU and timer channel?

Posted: Thu Mar 15, 2012 7:12 pm
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

Re: ICU and timer channel?

Posted: Fri Mar 16, 2012 10:47 am
by mobyfab
The current ICU implementation only supports PWM input mode, right?

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

Thanks.

Re: ICU and timer channel?

Posted: Fri Mar 16, 2012 10:53 am
by Giovanni
It measures periods already, are you suggesting a different mode?

Giovanni

Re: ICU and timer channel?

Posted: Fri Mar 16, 2012 11:19 am
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.

Re: ICU and timer channel?

Posted: Fri Mar 16, 2012 1:52 pm
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

Re: ICU and timer channel?

Posted: Fri Mar 16, 2012 4:53 pm
by mobyfab
Yes I was thinking about using the four comparators. I'm gonna check how ST does that in their FW examples.

Thanks.

Re: ICU and timer channel?

Posted: Sun Mar 18, 2012 7:05 pm
by kgysmits
Any chance on using the quadrature encoder function through the ICU driver?

Re: ICU and timer channel?

Posted: Sun Mar 18, 2012 7:35 pm
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