Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 7 months ago.
entering sleep mode
Please forgive the question if it appears basic but here it is:
I've used the program on the LPC1768 as seen below, and I've ran it and I wanted to see the sleep function (initiated by the interrupt)) stopping the execution of the code and show that the clocks have been powered down (or stopped/paused) this is aimed at saving power on the bad boy. Its my belief that the interrupt will wake the mbed up and then it will carry on as normal showing the value from when the interrupt was applied (I wait a few seconds between applying the interrupt)... it doesn't.. in fact the clocks keeps cycling (which I respect but...) which means the while loop is still being processed and the mbed isn't sleeping (which I also respect but...) any help would be great
#include "mbed.h" InterruptIn event(p8); DigitalOut myled(LED1); Timer t; int go_to_sleep = 0; void pressed() { printf("Button pressed\n"); go_to_sleep = !go_to_sleep; } int main() { int i = 0; event.mode(PullUp); event.fall(&pressed); t.start(); while (1) { if (go_to_sleep) { myled = 1; printf("%d: Entering sleep (press user button to resume)",i); printf("timer is %2.2f\n\r",t.read()); sleep(); wait(0.1); } else { printf("%d: Running timer reads\n\r", i); printf("timer is %2.2f\n\r",t.read()); myled = !myled; wait(1.0); } i++;
The timer also started reading 00.00 when initiated after start up (or reset being pressed)
Any help would be greatly appreciated.. also any help in regards to the sleep function or deep sleep function would be nice as I've looked at the NXP LPC1768 and I wouldn't mind a little more help.
Thank you for your time,
1 Answer
10 years, 7 months ago.
Add <<code>> and <</code>>
to format the code.
The LPC1768 doesn't have deepsleep implemented, it simply calls sleep. In regular sleep timer peripherals keep running (just like all others, it has a fairly small effect on power consumption). In general the power consumption of the mbed LPC1768 is huge though, regardless if you put it in sleep or not. See: http://mbed.org/cookbook/Power-Management for some ideas on lowering it, without resorting to sleep.
what does the sleep function do after the function is called
Thanks for the reply
so calling the function only disconnects the interface "magic chip" and then prevents any dynamic blar blar and buses being used (as seen above)
Is it wrong to say that the NXP LPC1768 does have a deep sleep mode as evidenced above in the docs for the chip? and is it right in implying that if the individual chip could to forced into deep sleep it would have a significant impact on the power consumption?
Thanks again for the reply
posted by 25 Apr 2014Very little, this is the function:
void sleep(void) { #if (DEVICE_SEMIHOST == 1) // ensure debug is disconnected mbed_interface_disconnect(); #endif // PCON[PD] set to sleep LPC_SC->PCON = 0x0; // SRC[SLEEPDEEP] set to 0 = sleep SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; // wait for interrupt __WFI(); }
It disconnects itself from the interface first. Then it sets some registers to enter regular sleep mode, which WFI does.
posted by 25 Apr 2014