FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [July 2014 Threads] xTaskIncrementTick() could be called when pxCurrentTCB == NULLPosted 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 == NULLPosted 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 == NULLPosted 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
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|