]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c
Improvements to the Cortex-M ports:
[freertos] / FreeRTOS / Source / portable / RVDS / ARM_CM3 / port.c
index 61d85967d7c1420f9e0fcaed12115e9e8af987d9..8ce6d098d2e1b35d3ee9e5af2c5d0a8fa851cc1d 100644 (file)
@@ -407,6 +407,7 @@ __asm void xPortPendSVHandler( void )
 \r
        stmdb r0!, {r4-r11}                     /* Save the remaining registers. */\r
        str r0, [r2]                            /* Save the new top of stack into the first member of the TCB. */\r
+       clrex                                           /* Ensure thread safety of atomic operations. */\r
 \r
        stmdb sp!, {r3, r14}\r
        mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
@@ -621,6 +622,10 @@ void xPortSysTickHandler( void )
                }\r
                #endif /* configUSE_TICKLESS_IDLE */\r
 \r
+               /* Stop and clear the SysTick. */\r
+               portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+               portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
                /* Configure SysTick to interrupt at the requested rate. */\r
                portNVIC_SYSTICK_LOAD_REG = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
                portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT );\r