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




Loading

xTaskIncrementTick() could be called when pxCurrentTCB == NULL

Posted by dddddppppp on July 20, 2014

I’m running code, generated by STM32Cube and have dropped to HardFaultHandler() on start of execution. By debugging I have found this issue: STM32Cube code generator placed xPortSysTickHandler() into SysTickHandler() for 1 ms tick counting. xPortSysTickHandler() calls xTaskIncrementTick(), which execute follow code:

... if( listCURRENTLISTLENGTH( &( pxReadyTasksLists[ pxCurrentTCB->uxPriority ] ) ) > ( UBaseType_t ) 1 ) ...

But, clock system had initialized before any tasks have been created. And interrupt SysTick_Handler() may occurs when no tasks and even scheduler is not running yet. So, pointer pxCurrentTCB equal to zero at this moment and [pxCurrentTCB -> uxPriority] indicates some random value. It caused system exception.

As temporary solution I just have added one of task creation procedure before clock initialization. That is not good coding, but works.


xTaskIncrementTick() could be called when pxCurrentTCB == NULL

Posted by rtel on July 20, 2014

The clock should not be initialised until the scheduler has started. The sequence used by FreeRTOS is as follows:

1) Ensure interrupts are disabled. 2) Configure clock to generate tick interrupts. 3) Start the first task (which automatically re-enables interrupts).

So the clock initialisation code must itself be enabling the systick, which it need not do as FreeRTOS will do that itself at the appropriate time.

One solution for you, which assumes the ST code is not also enabling interrupts, is to simply call taskENTER_CRITICAL (or globally disable interrupts) before the clock initialisation is done. The scheduler will automatically set the global interrupts and critical section state to be correct when it starts.

Regards, Richard Barry.


xTaskIncrementTick() could be called when pxCurrentTCB == NULL

Posted by dddddppppp on July 23, 2014

Thanks Richard! ST promisses to fix it in the next version. So, I have decided to develop own project, using Cube as reference only. Based on examlpes from FreeRTOS package it work fine.

Regards. Dmitry Popov


[ 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