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

Possible Cortex-M tickless idle OBO's

Posted by J Hamilton on June 28, 2013
Atmel SAM4S (CM4), FreeRTOS 7.4.2, Atmel Studio (GCC)

In port.c, the systick reload value is calculated thus:
 ulTimerReloadValueForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; [\code]
... which makes sense according to the datasheet (SAM4S), but later, the code calculates how many 'normal' tick periods have passed in an extended sleep time:

/* Something other than the tick interrupt ended the sleep.
Work out how long the sleep lasted. */
ulCompletedSysTickIncrements = ( xExpectedIdleTime * ulTimerReloadValueForOneTick ) - portNVIC_SYSTICK_CURRENT_VALUE_REG;

/* How many complete tick periods passed while the processor
was waiting? */
ulCompleteTickPeriods = ulCompletedSysTickIncrements / ulTimerReloadValueForOneTick;
[\code]
In each of these calculations, shouldn't (ulTimerReloadValueForOneTick + 1) be used instead of ulTimerReloadValueForOneTick due to the fact that the period is actually one more than the reload value?

This hasn't caused any issues that I know of so far and the reload values are usually quite large so the error is small, but I thought I would ask/point this out.

Thanks.

RE: Possible Cortex-M tickless idle OBO's

Posted by J Hamilton on June 28, 2013
Atmel SAM4S (CM4), FreeRTOS 7.4.2, Atmel Studio (GCC)

In port.c, the systick reload value is calculated thus:
ulTimerReloadValueForOneTick = ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL; 

... which makes sense according to the datasheet (SAM4S), but later, the code calculates how many 'normal' tick periods have passed in an extended sleep time:

/* Something other than the tick interrupt ended the sleep.
Work out how long the sleep lasted. */
ulCompletedSysTickIncrements = ( xExpectedIdleTime * ulTimerReloadValueForOneTick ) - portNVIC_SYSTICK_CURRENT_VALUE_REG;

/* How many complete tick periods passed while the processor
was waiting? */
ulCompleteTickPeriods = ulCompletedSysTickIncrements / ulTimerReloadValueForOneTick;

In each of these calculations, shouldn't (ulTimerReloadValueForOneTick + 1) be used instead of ulTimerReloadValueForOneTick due to the fact that the period is actually one more than the reload value?

This hasn't caused any issues that I know of so far and the reload values are usually quite large so the error is small, but I thought I would ask/point this out.

Thanks.
P.S Can someone delete the previous post with bad formatting?

RE: Possible Cortex-M tickless idle OBO's

Posted by Richard on June 28, 2013
Thanks for pointing this out - it is not the first time I have made similar errs, and probably won't be the last. There is also one other change that needs to be made to the tickless implementation in the circumstance that an interrupt other than the tick brings the MCU out of low power. I will try and address these issues shortly.

Regards

[P.S. Unfortunately I can't delete your post]

RE: Possible Cortex-M tickless idle OBO's

Posted by J Hamilton on June 28, 2013
Thank you. I look forward to seeing the changes and learning from your implementation.

RE: Possible Cortex-M tickless idle OBO's

Posted by Richard on June 30, 2013
I have refined the implementation in all the ports:

http://freertos.svn.sourceforge.net/viewvc/freertos/trunk/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c?revision=1957&view=markup

Regards.


[ 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