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

Cortex M3 Tickless Idle

Posted by Phil B on August 14, 2013
I'm trying to understand the CM3 / GCC port implementation of vPortSuppressTicksAndSleep. I think I understand everything except for the behaviour when entry to low power mode is aborted due to eTaskConfirmSleepModeStatus() returning eAbortSleep.


/* If a context switch is pending or a task is waiting for the scheduler
to be unsuspended then abandon the low power entry. */
if( eTaskConfirmSleepModeStatus() == eAbortSleep )
{
/* Restart SysTick. */
portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT;

/* Re-enable interrupts - see comments above the cpsid instruction()
above. */
__asm volatile( "cpsie i" );
}


My understanding from the CM3 core documentation is that writing NVIC_SYSTICK_ENABLE_BIT will reload the value from the SYSTICK_LOAD_REG and start counting down. Thus if the entry into sleep mode is aborted, the SYS_TICK interval is restarted, loosing any of the tick period that has elapsed so far.

Given the amount of effort expended in trying to correct for lost clocks to the SYS_TICK timer when it is disabled and then re-enabled when the tick-less period is generated by extending the SYS_TICK period, this seems like a bit of an oversight. I therefore expect I've missed a subtlety in the implementation.

Can someone (Richard?) explain what I've missed and why restarting the SYS_TICK timer without making a prior adjustment to the reload register is OK?

Thanks,
Phil.

RE: Cortex M3 Tickless Idle

Posted by Richard on August 15, 2013
You are correct, this is an anomaly. It is very hard to get the code to go through that path, but for completeness it should be fixed.

I think copying the current count value into the reload register, starting the timer, then resetting the reload register back to its "normal" value for a tick period should be ok.

Do you agree?

Regards.

RE: Cortex M3 Tickless Idle

Posted by Phil B on August 15, 2013
Thanks Richard, that's exactly how I would resolve the issue.

There's obviously going to be a small drift due to the time taken to execute eTaskConfirmSleepModeStatus which I guess could be estimated in the same way you've already done for the other path, but given the likely infrequent execution of this path compared with the normal path, it's probably not that important. I think it's reasonable to expect some drift when using tick-less idle.

Regards,

Phil.


[ 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