KSDK 2.0 + Kinetis Bootloader v1.2.0 + FreeRTOS V8.2.3

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KSDK 2.0 + Kinetis Bootloader v1.2.0 + FreeRTOS V8.2.3

828 Views
thcooke77
Contributor III

A warning to all:

If you are using the Stock Kinetis Bootloader v1.2.0 and a Project using the FreeRTOS included with KSDK 2.0 there is a problem with the Systick initialization.

 

The Kinetis Bootloader uses Systick for its timers. When in the bootloader deinits the Systick it does not clear the SYSTICK_CURRENT_VALUE_REG. When the freertos scheduler starts under certain situations the Systick will not fire untill the SYSTICK_CURRENT_VALUE_REG completely rolls over causing an assert to happen when using tickless idle mode.

 

If you do not want to change the stock bootloader code you must make a  slight change to the vPortSetupTimerInterrupt() initialization in port.c (or define your own because it is weakly defined).

 

Below is what will always work (Additions in blue):

/* Configure SysTick to interrupt at the requested rate. */

// Clear out the CTRL Register (Just in case it happened to be running)

portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CTRL_REG &

       ~( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT |

            portNVIC_SYSTICK_ENABLE_BIT );

// Load the reload value

portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;

// Clear out any current values from the bootloader

portNVIC_SYSTICK_CURRENT_VALUE_REG = 0;

// Enable the systick timer

portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT |

            portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );

 

Terry Cooke

Labels (1)
0 Replies