Skip to content

Commit 13acfbe

Browse files
committed
Corrected SysTick_Handler and osKernelGetSysTimerCount to cope with tickless idle implementation (#60)
1 parent 8381c64 commit 13acfbe

7 files changed

Lines changed: 54 additions & 2 deletions

File tree

ARM.CMSIS-FreeRTOS.pdsc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Corrected osEventFlagsSet return value when called from ISR
1717
- Corrected osEventFlagsWait to return osFlagsErrorParameter when called from ISR with non-zero timeout
1818
- Corrected osTimerStart to return osErrorParameter when ticks argument equals zero
19+
- Corrected SysTick_Handler and osKernelGetSysTimerCount to cope with tickless idle implementation
1920
- Re-enable interrupts after mutex create in C lib stream protection initialization
2021
</release>
2122
<release version="10.4.6" date="2021-11-16">

CMSIS/RTOS2/FreeRTOS/Config/ARMCM/FreeRTOSConfig.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@
8888
// <i> Default: 1
8989
#define configUSE_TIME_SLICING 1
9090

91+
// <q>Use tickless idle
92+
// <i> Enable low power tickless mode to stop the periodic tick interrupt during idle periods or
93+
// <i> disable it to keep the tick interrupt running at all times.
94+
// <i> Default: 0
95+
#define configUSE_TICKLESS_IDLE 0
96+
9197
// <q>Idle should yield
9298
// <i> Control Yield behaviour of the idle task.
9399
// <i> Default: 1

CMSIS/RTOS2/FreeRTOS/Examples/Blinky/RTE/RTOS/FreeRTOSConfig.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@
8888
// <i> Default: 1
8989
#define configUSE_TIME_SLICING 1
9090

91+
// <q>Use tickless idle
92+
// <i> Enable low power tickless mode to stop the periodic tick interrupt during idle periods or
93+
// <i> disable it to keep the tick interrupt running at all times.
94+
// <i> Default: 0
95+
#define configUSE_TICKLESS_IDLE 0
96+
9197
// <q>Idle should yield
9298
// <i> Control Yield behaviour of the idle task.
9399
// <i> Default: 1

CMSIS/RTOS2/FreeRTOS/Examples/Blinky_IAR/Blinky/RTE/RTOS/FreeRTOSConfig.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* --------------------------------------------------------------------------
2-
* Copyright (c) 2013-2021 Arm Limited. All rights reserved.
2+
* Copyright (c) 2013-2022 Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -17,7 +17,7 @@
1717
*
1818
* --------------------------------------------------------------------------
1919
*
20-
* $Revision: V10.3.0
20+
* $Revision: V10.4.0
2121
*
2222
* Project: CMSIS-FreeRTOS
2323
* Title: FreeRTOS configuration definitions
@@ -88,6 +88,12 @@
8888
// <i> Default: 1
8989
#define configUSE_TIME_SLICING 1
9090

91+
// <q>Use tickless idle
92+
// <i> Enable low power tickless mode to stop the periodic tick interrupt during idle periods or
93+
// <i> disable it to keep the tick interrupt running at all times.
94+
// <i> Default: 0
95+
#define configUSE_TICKLESS_IDLE 0
96+
9197
// <q>Idle should yield
9298
// <i> Control Yield behaviour of the idle task.
9399
// <i> Default: 1
@@ -192,6 +198,12 @@
192198
// <i> Default: 1
193199
#define configENABLE_FPU 1
194200

201+
// <q>Use M-Profile Vector Extension
202+
// <i> Using M-Profile Vector Extension (MVE) affects context handling.
203+
// <i> Enable MVE when application uses signal processing and ML algorithms.
204+
// <i> Default: 0
205+
#define configENABLE_MVE 0
206+
195207
// <q>Use Memory Protection Unit
196208
// <i> Using Memory Protection Unit (MPU) requires detailed memory map definition.
197209
// <i> This setting is only releavant for MPU enabled ports.

CMSIS/RTOS2/FreeRTOS/Examples/TrustZone/NonSecure/RTE/RTOS/FreeRTOSConfig.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@
8888
// <i> Default: 1
8989
#define configUSE_TIME_SLICING 1
9090

91+
// <q>Use tickless idle
92+
// <i> Enable low power tickless mode to stop the periodic tick interrupt during idle periods or
93+
// <i> disable it to keep the tick interrupt running at all times.
94+
// <i> Default: 0
95+
#define configUSE_TICKLESS_IDLE 0
96+
9197
// <q>Idle should yield
9298
// <i> Control Yield behaviour of the idle task.
9399
// <i> Default: 1

CMSIS/RTOS2/FreeRTOS/Source/cmsis_os2.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,10 @@ extern void xPortSysTickHandler (void);
154154
SysTick handler implementation that also clears overflow flag.
155155
*/
156156
void SysTick_Handler (void) {
157+
#if (configUSE_TICKLESS_IDLE == 0)
157158
/* Clear overflow flag */
158159
SysTick->CTRL;
160+
#endif
159161

160162
if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) {
161163
/* Call tick handler */
@@ -474,17 +476,35 @@ uint32_t osKernelGetSysTimerCount (void) {
474476
uint32_t irqmask = IS_IRQ_MASKED();
475477
TickType_t ticks;
476478
uint32_t val;
479+
#if (configUSE_TICKLESS_IDLE != 0)
480+
uint32_t val0;
481+
482+
/* Low Power Tickless Idle controls timer overflow flag and therefore */
483+
/* OS_Tick_GetOverflow may be non-functional. As a workaround a reference */
484+
/* time is measured here before disabling interrupts. Timer value overflow */
485+
/* is then checked by comparing reference against latest time measurement. */
486+
/* Timer count value returned by this method is less accurate but if an */
487+
/* overflow is missed, an invalid timer count would be returned. */
488+
val0 = OS_Tick_GetCount();
489+
#endif
477490

478491
__disable_irq();
479492

480493
ticks = xTaskGetTickCount();
481494
val = OS_Tick_GetCount();
482495

483496
/* Update tick count and timer value when timer overflows */
497+
#if (configUSE_TICKLESS_IDLE != 0)
498+
if (val < val0) {
499+
ticks++;
500+
}
501+
#else
484502
if (OS_Tick_GetOverflow() != 0U) {
485503
val = OS_Tick_GetCount();
486504
ticks++;
487505
}
506+
#endif
507+
488508
val += ticks * OS_Tick_GetInterval();
489509

490510
if (irqmask == 0U) {

DoxyGen/General/src/cmsis_freertos.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ File/Directory |Content
6565
<li>Corrected osEventFlagsSet return value when called from ISR</li>
6666
<li>Corrected osEventFlagsWait to return osFlagsErrorParameter when called from ISR with non-zero timeout</li>
6767
<li>Corrected osTimerStart to return osErrorParameter when ticks argument equals zero</li>
68+
<li>Corrected SysTick_Handler and osKernelGetSysTimerCount to cope with tickless idle implementation</li>
6869
<li>Re-enable interrupts after mutex create in C lib stream protection initialization (#55)</li>
6970
</ul>
7071
</td>

0 commit comments

Comments
 (0)