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.
[DONE]32bit Timers on STM32F4
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: 32bit Timers on STM32F4
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
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
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.
What I'm really proposing is changing gptcnt_t to be uint32_t instead of uint16_t.
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: 32bit Timers on STM32F4
You could give it a try, that cast is not even strictly required.
Giovanni
Giovanni
Re: 32bit Timers on STM32F4
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.
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: 32bit Timers on STM32F4
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
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
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.
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.
- Attachments
-
- gpt_lld.h.patch.zip
- (485 Bytes) Downloaded 437 times
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times