TIM1 as System Timer?

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

Moderator: RoccoMarco

Post Reply
jamarju
Posts: 1
Joined: Thu Jan 28, 2016 9:14 pm

TIM1 as System Timer?

Post by jamarju »

Hello, and thanks in advance for this great software. I teach robotics and this is my first attempt at using a RTOS with students. I'm coming from the Arduino world where everything is busy wait. Also new to ARM, so I'm facing a few questions that are not so clear by looking at the doxygen / source code.

I'm using a STM32F103C8T6 MCU (aka $2.5 dev board from aliexpress, aka "the blue board with the yellow headers", aka "Bluepill / Redpill") to build a robot. I'm using TIM2, 3 and 4 for PWM and quadrature encoder inputs, so I only have TIM1 left.

First question... I see that the only valid values for STM32_ST_USE_TIMER are 2, 3 and 4. But because I'm using the LQFP48 package and a bunch of other peripherals, TIM1 is my only leftover timer. Is there any way to use TIM1?

Which brings another question. Why is even a regular timer necessary when I can use the cortex core systick timer?

The third question is... What's the best way to do a 10 uS delay, either interrupt-driven or polled? My understanding is that chThdSleepMilliseconds is limited by the SysTick resolution.

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

Re: TIM1 as System Timer?

Post by Giovanni »

Hi,

The timer are only required in tickless mode, if you use the normal tick mode then systick is used as timer (set delta=0 frequency=1000 in chconf.h), systick is not usable in tickess mode because its limitations.

You can use interrupts in the 10uS time domain but the jitter is going to be significant.

You could use TIM1 for tickless but it requires (easy) changes to the ST driver, you could attempt it, just follow the patterns. It is not there because TIM1 is meant to be an "advanced" timer and is wasted as system timer.

Giovanni
Post Reply