curran.danny

HAL_IncTick() when systick is used by a RTOS

Discussion created by curran.danny on Mar 16, 2018
Latest reply on Mar 19, 2018 by dhenry

The code produced by MxCube uses the systick interrupt to increment a tick count, (via HAL_IncTick())

 

But when  a projects is using a RTOS , the systick interrupt vector can be declared else where e.g. Keil RTX,  so it has to be removed form the Interrupt Service Routines file for example in stm32f1xx_it.c and HAL_IncTick() is no longer called.

 

But  HAL_GetTick()  is used in lots of the CMSIS  peripherals driver code to detect time outs and device errors etc. 

 

Can the Cube software be changed, so that  there is a warning that when used with an RTOS using the systick interrupt some parts of HAL drivers will be functionally broken ( eg timeouts will no longer work in case of peripheral faults). 

 

what is the suggested ST workaround for this issue ?

 

e.g. Remove the peripheral init code from main and move it to a place where the RTOS Kernel is running  eg first task.

then put a call to get the RTOS tick count in HAL_GetTick() 

 

e.g. in stm32f1xx_hal.c

uint32_t HAL_GetTick(void)
{

   return  osKernelGetTickCount();
}

 

Thanks Danny

Outcomes