Page 1 of 1

[DONE]32bit Timers on STM32F4

Posted: Sun Jun 30, 2013 3:17 am
by talsit
Hi there!

TIM2/5 are both 32bit timers, but, from what I can see, they can't be uses as that, just as 16bit, since there's quite a few places where parameters are cast into uint16_t.

Is there any reason I can't modify code to allow the full 32bit range?

Thanks.

Re: 32bit Timers on STM32F4

Posted: Sun Jun 30, 2013 7:38 am
by Giovanni
Hi,

You could, the problem is that TIM2 an TIM5 are not 32bits on all devices so the driver supports them only in 16bits mode.

It could be improved to support both modes but changes would be extensive. This would impact the GPT, ICU and PWM drivers.

Giovanni

Re: 32bit Timers on STM32F4

Posted: Sun Jun 30, 2013 7:44 am
by talsit
The only thing I can see from allowing them to be 32bit is (at least for the STM32F4 port), that gpt_lld_change_interval() casts the value to a uint16_t.

What I'm really proposing is changing gptcnt_t to be uint32_t instead of uint16_t.

Re: 32bit Timers on STM32F4

Posted: Sun Jun 30, 2013 8:17 am
by Giovanni
You could give it a try, that cast is not even strictly required.

Giovanni

Re: 32bit Timers on STM32F4

Posted: Sun Jun 30, 2013 5:26 pm
by talsit
I did remove the cast. Well, I now cast as a gptcnt_t instead of uint16_t, and I also changed the typedef of gptcnt_t to be a uint32_t. That actually makes it all work nice.

Re: 32bit Timers on STM32F4

Posted: Sun Jun 30, 2013 5:36 pm
by Giovanni
Hi,

Please post a patch if you can. I think that differences among 16 an 32 bit times should be handled somehow, using assertions for example.

Giovanni

Re: 32bit Timers on STM32F4

Posted: Wed Jul 03, 2013 12:29 am
by talsit
I've attached the patch, which is only 2 lines really.
It may be possible to move the typedef to the config file, would that makes sense? Or maybe through some #ifdefs.
But yes, my timers are now 32-bit compatible.

Re: [TODO]32bit Timers on STM32F4

Posted: Thu Aug 15, 2013 9:27 am
by Giovanni
Hi,

Patch merged, it will be in 2.6.1.

Giovanni

Re: [DONE]32bit Timers on STM32F4

Posted: Thu Aug 15, 2013 11:43 am
by talsit
Awesome, thanks!