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: [code] /* 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 [b](ulTimerReloadValueForOneTick + 1)[/b] be used instead of [b]ulTimerReloadValueForOneTick[/b] 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.