STM32F303K8 and SysTick timer

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
Apache
Posts: 11
Joined: Sat Jan 30, 2021 7:31 pm
Has thanked: 1 time
Been thanked: 1 time

STM32F303K8 and SysTick timer

Post by Apache »

Hello,

I need to use something else than TIM1, 2 or 3 as a SysTick timer, but the timers i have are not supported in hal_st_lld.h . Is there as specific reason why I can't use the other timers on my chip or are they just not implemented?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F303K8 and SysTick timer

Post by Giovanni »

Hi,

Which version are you using? timers should be all supported now.

You can use SysTick as system timer by putting the "delta" parameter to zero in chconf.h (this disables the tick-less mode), in this case make sure to not exceed 1000Hz as system tick frequency.

Giovanni
Apache
Posts: 11
Joined: Sat Jan 30, 2021 7:31 pm
Has thanked: 1 time
Been thanked: 1 time

Re: STM32F303K8 and SysTick timer

Post by Apache »

I use the 20.3.X branch on the github repo.

The defines STM_ST_USE_TIMX are available for timers 2 to 5, 9 to 14, 21 and 22. On my MCU I have timers 1 to 3, 6, 7 and1 5 to 17, and I already use timers 1 to 3.

Thanks for the fast answer and the tip about tickless mode!
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F303K8 and SysTick timer

Post by Giovanni »

Only timers 2 and 5 are 32 bits wide, which is convenient for tick-less mode. In ticked mode all timers are free to use.

Giovanni
Apache
Posts: 11
Joined: Sat Jan 30, 2021 7:31 pm
Has thanked: 1 time
Been thanked: 1 time

Re: STM32F303K8 and SysTick timer

Post by Apache »

Using ticked mode worked fine! :D

Just to clarify, why are some 16 bits timers available and others aren't in tickless mode?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F303K8 and SysTick timer

Post by Giovanni »

Because the driver is not necessarily complete, if I remember well some more timers have been added in repository code.

Giovanni
User avatar
FXCoder
Posts: 403
Joined: Sun Jun 12, 2016 4:10 am
Has thanked: 188 times
Been thanked: 134 times

Re: STM32F303K8 and SysTick timer

Post by FXCoder »

Hi,
As Giovanni noted if you use trunk it has TIM15-17 implemented.
Porting the extra TIM updates back into 20.3.x can be done.
There is also a bug fix needed in 20.3.x for ALARMS handling (wrong indexing of callbacks) which is already fixed in trunk.
--
Bob
User avatar
FXCoder
Posts: 403
Joined: Sun Jun 12, 2016 4:10 am
Has thanked: 188 times
Been thanked: 134 times

Re: STM32F303K8 and SysTick timer

Post by FXCoder »

Hi Giovanni,
Patch for 20.3.x hal_st_lld
1. Include TIM-15-17
2. Update use of STM32_ST_OVERRIDE_ALARMS
For your review - not tested ATM.
--
Bob
Attachments
20_3_x_hal_st_lld_patch.zip
(2.23 KiB) Downloaded 405 times
Post Reply