heinbali01 wrote on Tuesday, 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 heap_4.c you can define ‘configAPPLICATION_ALLOCATED_HEAP=1’ and tell the compiler where (in which sector) to put the ucHeap[] block.
See heap_4.c :
#if( configAPPLICATION_ALLOCATED_HEAP == 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 uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
#else
uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
#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.