Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Tick-less FreeRTOS with LPC4337 and power down mode

Posted by h-pan on November 9, 2015

Hi,

I am working on project with Tick-less FreeRTOS using deep sleep low power mode of LPC4337 working on it. In Deep-sleep mode the CPU clock and peripheral clocks are shut down to save power; logic states and SRAM memory are maintained. Platform: LPC4337 Compiler:LPCXpresso7.9 FreeRTOS V8.0.1

Now I want to use Power Down mode in which all SRAM memory except for the upper 8 kB of the local SRAM located at 0x1008 0000 is maintain. In addition, Power down mode doesn't do system reboot it resume from last instruction after wake-up.

My question is how I can reallocate Stack and heap memory in this 8kb safe memory area? What are the variable I need to save before I goto power-down mode to resume the normal functionality after wake-up (task stack, system stack other required variable to maintain RTOS kernel?

Regards,


Tick-less FreeRTOS with LPC4337 and power down mode

Posted by heinbali01 on November 10, 2015

Hi Henna,

That is quite ambitious what you want to do! I never went further than "Power-save mode" and "Sleep mode", because that is much easier: clocks remain running.

the upper 8 kB of the local SRAM located at 0x1008 0000 is maintain[ed]

If you use 'portable/MemMang/heap_5.c' it is easy to tell where to put the HEAP.

Or when using heap4.c you can define 'configAPPLICATIONALLOCATED_HEAP=1' and tell the compiler where (in which sector) to put the ucHeap[] block.

See heap_4.c :

~~~~~ #if( configAPPLICATIONALLOCATEDHEAP == 1 ) /* The application writer has already defined the array used for the RTOS heap - probably so it can be placed in a special segment or address. */ extern uint8t ucHeap[ configTOTALHEAPSIZE ]; #else uint8t ucHeap[ configTOTALHEAPSIZE ]; #endif ~~~~~

Declare the HEAP space in your code:

~~~~~

__attribute__((aligned(8)))
__attribute__((section(".sram_high")))
    uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
/* '.sram_high' refers to a name defined in your xxx.ld
you will have to edit it. */

~~~~~

Doesn't your application need a notion of time, a continuous clock?

reallocate Stack and heap memory

There is a temporary start-up stack that can be allocated anywhere, see your link file 'xxx.ld'. After vTaskStartScheduler() is called, only FreeRTOS stacks are in use, and these stacks are located in the HEAP ( by xTaskCreate() ).

Have you also tried-out lighter ways of sleeping? Normally the tickless mode uses the system clock or a hardware timer (TC*) to count-down. That makes it possible to use the timed blocking options of FreeRTOS. *TC's are preferable if you need long sleeps, they often have a 32-bit counter.

Some things are important for power consumption in the low-power/sleep modes :

  • Low CPU frequencies consume much less power. You might consider implementing an on-demand variable CPU frequency ( in analogy with the Linux kernel ).

GPIO's are very important:

  • Make sure that inputs are never floating.
  • If an input has an internal pull-up, make sure it is not tied to ground
  • Same for outputs, make sure there is no current running

  • Make sleeps long enough, preferably at least 30 seconds.

Some more questions:

  • How many µA is your application allowed to consume while in low power?
  • Does it wake-up often? How long is is allowed to remain in low power?
  • What are the events that will wake-up your application?

Regards.


Tick-less FreeRTOS with LPC4337 and power down mode

Posted by h-pan on November 13, 2015

Hi Hein,

Thank you for such an elaborated answer.

About questions you asked: 1. In low power mode my application is allowed to consume 100uA. 2. The sleep time is variable and it can be from 1 min to several hours. 3. I am using default implementation of tickless and Alarm timer, External trigger and RTC alarm timer as a wake up source.

As you suggest I have changed to heap4 earlier I was using heap3. I modified the linker file to allocate the 4 kB of the local SRAM starting at location 0x1008 8000 with heap size 4kB as a freertos heap memory. I confirmed the proper heap allocation by printing the stack pointer using asm instruction. (I got SP = 1x10088678, which is in the 4kB safe memory area allocated to heap).

Now after this modification I am able to go-to power down mode and wake up if any wake-up source triggers, but my application goes to hard fault once the global interrupts are enabled. I am not sure what are the variable I need to save before I go-to power-down mode.

http://www.freertos.org/FreeRTOSSupportForumArchive/July2013/freertosFreeRTOSwithstandbymodeinSTM32_8557400.html

This thread suggests every static variables in task.c must be saved, I am doing this using header file and __DATA(RAM) macro to locate task.c variables in this 8kB memory area.

I am not sure why my code is going into hard-fault after enabling the global interrupt. Am I missing something? Any idea?


Tick-less FreeRTOS with LPC4337 and power down mode

Posted by rtel on November 13, 2015

The variables used by FreeRTOS are qualified by the macro PRIVILEGED_DATA - although the macro is empty by default you can define it in FreeRTOSConfig.h to force the variables into a certain linker section.

Regards.


Tick-less FreeRTOS with LPC4337 and power down mode

Posted by heinbali01 on November 14, 2015
  1. In low power mode my application is allowed to consume 100uA.

Hm that's indeed a challenge!

  1. The sleep time is variable and it can be from 1 min to several hours.

I asked that to know if you can just power-down the device, and save essential information in flash or eprom?

Now after this modification I am able to go-to power down mode and wake up if any wake-up source triggers, but my application goes to hard fault once the global interrupts are enabled.

I would first think of the vector table, but that is declared const in flash section ".isr_vector", I suppose?

This thread suggests every static variables in task.c must be saved, I am doing this using header file and __DATA(RAM) macro to locate task.c variables in this 8kB memory area.

Can your compiler produce a .SYM or .MAP file that shows all variables? And then look at all variables that are not saved during low-power?

Isn't it possible to change your .LD file and only use the safe (saved) part of SRAM? Or you might also use the other RAM areas, as long as you make the access very explicit.

Regards.


Tick-less FreeRTOS with LPC4337 and power down mode

Posted by h-pan on November 16, 2015

Thanks rtel for your prompt reply.

I was already using header file and _DATA(RAM) macro to locate variables qualified by PRIVILEGEDDATA in task.c in this 8kB memory area.

In addition there are some variables in port.c which has to be saved before going into power down mode.

Regards,


Tick-less FreeRTOS with LPC4337 and power down mode

Posted by h-pan on November 16, 2015

Hi Hein,

I truly appreciate your time and effort.

I would first think of the vector table, but that is declared const in flash section ".isr_vector", I suppose?

Yes, Vector table is stored in flash memory.

Can your compiler produce a .SYM or .MAP file that shows all variables? And then look at all variables that are not saved during low-power?

Yes LPCxpresso creates .map file which helped me a lot to look at the address of variables in safe and different RAM sections.

The good news is I got Tick-less FreeRTOS working with power down mode. I split the safe RAM into two areas one for storing freertos variables (2kB) and other for heap (6kB). Also, I had to modify .LD file to use safe part of SRAM.

Regards,


Tick-less FreeRTOS with LPC4337 and power down mode

Posted by heinbali01 on November 17, 2015

Very well, thanks for notifying..

Of course it is still possible to put the other RAM area in a special section and declare variables that you can use during a wake-up session only, the contents is gone after a sleep:

~~~~~ attribute((section(".nonpermanentram"))) unsigned temporary_space[ 1024 ]; ~~~~~

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS