FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [June 2013 Threads] Possible Cortex-M tickless idle OBO'sPosted 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'sPosted 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'sPosted 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'sPosted 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'sPosted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|