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

Dynamic clock frequency

Posted by maxter on July 18, 2013
It has been three years when that same question was made:

http://www.freertos.org/FreeRTOS_Support_Forum_Archive/July_2010/freertos_Dynamic_clock_frequency_3778272.html

At that time Richard said that there wasn't so many people interested in the topic. Three years later, power-savings is a big concern for a lot of engineers.

Changing the clock frequency as the system is running makes a lot of sense, and virtually all microcontrollers are able to run from different clock sources:

1.- From very innacurate low frequency internal clock (the one used for the watchdog, for example)
2.- From an accurate RC internal clock
3.- From an accurate external 32KHz (RTC)
4.- And the king of all, external high frequency and very accurate crystal based oscillator.
(5.- And all of them

So it would be nice to move from one source to another as the power requirements dictates. The (any) RTOS should adapt to the application, and not in the opposite direction.

As far as I know the newest FreeRTOS feature towards power-saving is the tickless one, that in its own is a big step.

So the question is: FreeRTOS has a mechanism that follows any dynamic clock frequency change?

Thank you!!

RE: Dynamic clock frequency

Posted by Richard on July 19, 2013
It would still be tricky to achieve this because of the way FreeRTOS manages Blocked lists [explanation at the bottom], but simplified greatly if there was the restriction that the tick frequency had to remain constant as the underlying clock frequency was changed dynamically. Therefore, each time the clock frequency was changed, a function would need to be called that re-configured whichever peripheral was generating the tick interrupt, or switched to a different peripheral to generate the tick interrupt, to ensure the clock change didn't result in a tick frequency change.


Here is the reason it would be tricky (although I like a challenge) if the clock change were to result in a tick frequency change:

Some RTOSes (that care less about performing non-deterministic list walking each time the time changes than does FreeRTOS) store block times as a counter that is counted down on each tick. When the counter reaches zero the task is moved out of the Blocked state. This is a crude method, but does allow for dynamic clock frequency changes as the Blocked tasks are served on each tick and the clock frequency known on each tick.

FreeRTOS does however have a policy of never performing non-deterministic actions in interrupts, and so instead places Blocked tasks in their wake time order. Therefore only the front of the list needs to be examined in most tick interrupts. You can see then that if a task wanted to unblock in 100ms time, and set an unblock tick time accordingly, only to have the number of ticks that made up 100ms change while the task was blocked, the task would be moved out of the Blocked state at the wrong time.

If the tick frequency were to half due to a clock change, then it would be possible to increment the tick count by two on each tick to ensure the time base as seen by the tasks didn't change, but the RTOS would still need to be informed that it needed to do that using a new API function.

It is an interesting topic. If this is a big deal for you, and you think also other people, then please add it to the feature request tracker in SourceForge.

Regards.

RE: Dynamic clock frequency

Posted by maxter on July 23, 2013
I do agree in the sense that, for now, the best option is to scale the system frequency down accordingly to the tick system,

Thank you!!


[ 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