New Cortex-M0 mbed caught having a snooze!


Here is the new Cortex-m0 board being sent to sleep, woken up by a button to increment and update a screen, then going back to sleep:

It is running from a couple of AA's, and takes a couple of mA when not doing anything.

Chris hooked this up yesterday for us to test some new sleep() and deepsleep() functions of the mbed C/C++ SDK. The code for this example uses deepsleep(), and looks like:

Simple deepsleep and interrupt wakeup example

#include "mbed.h"
#include "TextLCD.h"

TextLCD lcd(p21, p23, p24, p25, p26, p27);
InterruptIn wakeup(p14);

int i = 0;

void count() {
    lcd.locate (0,1);
    lcd.printf("%d",i);
    i++;
    wait(0.5);
}

int main () {
    wakeup.rise(NULL);  // Setup rising edge interrupt (no handler function needed)

    lcd.printf("Hello World!");

    while (1) {
        deepsleep();  // Deep sleep until external interrupt
        count();      // We've come out of sleep due to interrupt, so count!
    }
}

For both sleep() and deepsleep(), all state is retained so you can see it is a nice simple programming model. Should be great for quickly prototyping some things that need to run off batteries.

So all is looking good; hope you'll like it!

For more info on this cortex-m0 board as it goes through beta to release, you can signup to:

16 comments on New Cortex-M0 mbed caught having a snooze!:

24 Oct 2011

Is it 1.5mA supply current including the LCD, or 1.5mA into the processor module only?

25 Oct 2011

Hi Rod,

That 1.5mA was for the processor module only - I set it up to measure just the processor, as that was the bit we were interested in.

For interest, the LCD came in at a surprisingly high 2.4mA. I was surprised by that, I would have thought it was much lower current than that.

Thanks, Chris

25 Oct 2011

What frequency is this Cortex M0 running at ?

25 Oct 2011

48 MHz

29 Mar 2012

Is the magic chip turned off in deepsleep() too ?

29 Mar 2012

I just realized that the M0 mbed can be powered from the VB input unlike the M3 mbed and that only the LPC11U24 will get powered through it. Still, my current numbers show 14-15mA instead of <2mA.

#include "mbed.h"

DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);

int main() {
     wait(4);
     // LEDs seem to be slightly on for some reason
     led1 = 0;
     led2 = 0;
     led3 = 0;
     led4 = 0;
     //wait(4);
     //int res = semihost_powerdown();
     wait(4);
     // Go to Sleep
     while (1) {
         deepsleep();
     } 
}
24 Apr 2012

Zainul Charbiwala wrote:

I just realized that the M0 mbed can be powered from the VB input unlike the M3 mbed and that only the LPC11U24 will get powered through it. Still, my current numbers show 14-15mA instead of <2mA.

I am having the same problem. Has anyone else experienced this and perhaps found a solution?

25 Apr 2012

I dont have the LPC11U24 myself, but Chris Styles wrote on http://mbed.org/handbook/mbed-NXP-LPC11U24

Chris Styles wrote:

The use case scenarios are :

  • Power the whole mbed from USB, as normal. This takes 60mA
  • Power the whole mbed from Vin, as above but with a 4.5v-9.0v range. This also takes 60mA
  • Power 'just the LPC11U24' from VB. This has the range 1.8v-3.3v, and will take 16mA normally, and will drop to about 3mA in Sleep and 800uA when in Deep Sleep.

As there is no RTC to back up, it doesnt make sense to connect a coin cell cell.

The intention was that you can connect 2xAA batteries to VB, which gives you about a week of runtime.

If you make use of the sleep functionality, you get about a month, if you use deep sleep you get about 3 months.

@Ceri - We've opted to use the sleep modes that retain state as this makes the programmers model very clean, and it gets you down to 3 months on 2xAA batteries. Its worth remembering that depending on the quality of your batteries (especially if they are NiMH), you might find that the self-discharge is the same as (or more than) the drain from the mbed NXP LPC11U24 in deep sleep!

So 16 mA is normal mode. Lower currents are possible in Sleep or DeepSleep modes. Make sure you have the most recent mbed libs.

26 Apr 2012

I was using identical code to that posted in the video (barring the LCD display portions) and powering from 3.3V at VB. This should put it in deepsleep mode and yet still it draws 14-15mA

Wim Huiskamp wrote:

Make sure you have the most recent mbed libs

I don't believe I have any options other than #include "mbed.h" as far as the most recent mbed library goes. Am I wrong? As a sanity check I powered down all peripherals (LPC_SYSCON->PDRUNCFG |= 0xFF;) and then executed the WFI() command. Even this still took 4.5 mA! What am I missing?

26 Apr 2012

Paul Martin wrote:

I don't believe I have any options other than #include "mbed.h" as far as the most recent mbed library goes. Am I wrong?

Im not an expert on powerdowm modes, but you can check for the most recent mbed lib by clicking on the lib in your project tree. The IDE will check the version and allow an update (lib details window in upper right corner).

26 Apr 2012

What about the M3 ?

I have been trying to get a bare metal LPC1768 to run at very low power.

I have looked at quite a few forum posts, but cannot get lower than 8mA. Does anyone have some sudgestions ??

Cheers

Ceri.

26 Apr 2012

Wim Huiskamp wrote:

Im not an expert on powerdowm modes, but you can check for the most recent mbed lib by clicking on the lib in your project tree. The IDE will check the version and allow an update (lib details window in upper right corner).

Thanks, the library says it is up to date but the problem persists.

ceri clatworthy wrote:

What about the M0 ?

I am currently trying this on the M0 / LPC11U24

25 May 2012

Has no one else tried to verify this? It seems I am at least the second person that cannot get the m0 to yield the same current measurement. Does anyone from NXP / mbed have any comments on the matter? The architecture itself is a bit of a pain; I've just spent a few days trying to get an LPC11u14 in as low a power mode as possible, succeeding only in a few hundred uA, but the deepsleep mode on the mbed m0 flat out does not work!

13 Nov 2013

The code failed to compile for use on the KL25Z platform. Why?

13 Nov 2013

Wattanapong Kurdthongmee wrote:

The code failed to compile for use on the KL25Z platform. Why?

Because the example shared in the post above uses pinouts name for the another platform (NXP) - pxx. Change them to your platform.

13 Mar 2014

I have tried that code with my LPC11U35.. It goes down to deepsleep mode (I see 15mA consumption instead of run mode 29mA consumption) but it wont wake up..! I have tried with P0_22 pin and P0_16 pin as the interrupt source which are also my control buttons but never worked.. Do yu have any idea why it didnt work?

You need to log in to post a discussion