Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


systick slow start on CortexM0+ port with STM32L051C8, bug?

Posted by lobaro on January 13, 2017


we use the STM32l051c8 CortexM0+ MCU with the gcc port ("...portable/GCC/ARM_CM0") on FreeRTOS V9.0.0.

The mcu is clocked by the MSI sysclock (~4.2MHz) and had a problem with the prvSetupTimerInterrupt function. On this MCU the reset value of the systick count ( @ Adr 0xe000e018 ) is 0xFFFFFF. The M0 port does not init the current value register. Moreover the systick current value is above the initialized reload value. This leads to the problem that (at least with this MCU) the systick has to count down to zero for full 24bits. With our setup this brings a ~4seconds delay before the first systick irq is executed...

Our solution was add a reset of the current value register in prvSetupTimerInterrupt to zero:


define portNVICSYSTICKCURRENTVALUE ( ( volatile uint32t *) 0xe000e018 )

void prvSetupTimerInterrupt( void ) { /* Configure SysTick to interrupt at the requested rate. */ *(portNVICSYSTICKCURRENTVALUE) = 0; *(portNVICSYSTICKLOAD) = ( configCPUCLOCKHZ / configTICKRATEHZ ) - 1UL; *(portNVICSYSTICKCTRL) = portNVICSYSTICKCLK | portNVICSYSTICKINT | portNVICSYSTICK_ENABLE;

} ~~~

systick slow start on CortexM0+ port with STM32L051C8, bug?

Posted by rtel on January 13, 2017

Hi Tobias - thank you for taking the time to report this. I think this issue has already been noted and fixed.


systick slow start on CortexM0+ port with STM32L051C8, bug?

Posted by pkinzer on February 10, 2017


This bug still exists in FreeRTOS v9.0.0, for the ARM CM0 port, using IAR. I happen to be using it on an STM32F091 part. The source clearly does not initialize the SYST_CVR register. This particular part has a power-up value of 0xFFFFFF, which results in a 350ms delay before the first tick occurs, at 48MHz. My solution was to use the CMSIS call, which properly initializes the SysTick peripheral, so the first tick occurs in 1mS, in my case:

~~~ static void prvSetupTimerInterrupt( void ) { SysTickConfig(configCPUCLOCKHZ/configTICKRATE_HZ); } ~~~

It now works as expected, in 1mS, the first SysTick interrupt occurs. This one took me a while to track down, but it was an interesting challenge. :) See section 4.4 of the official ARM Cortex-M0 Generic User Guide for details on the SYST_CVR register:




systick slow start on CortexM0+ port with STM32L051C8, bug?

Posted by rtel on February 10, 2017

See line 252 (at the time of writing) in the following file: https://sourceforge.net/p/freertos/code/HEAD/tree/trunk/FreeRTOS/Source/portable/IAR/ARM_CM0/port.c

...it has been fixed. If you think the fix is wrong please let us know.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists