LPC1114 Low Power Experimenting

Question about power
Post Reply
armnewbee
Posts: 3
Joined: Fri Feb 15, 2013 11:34 pm

LPC1114 Low Power Experimenting

Post by armnewbee » Sat Feb 16, 2013 12:11 am

I'm experimenting with interrupts and low power modes on the BasicChip. I've set a goal to create a simple program to sleep for one second, wake via a counter match, do something simple, then go back to sleep and repeat (all in Basic). I've read the LPC11xx User Manual and am confused between the counter peripheral interrupt configuration and the NVIC interrupt handlers.

I believe I understand how to initialize the counter match interrupt, what appears to be Exception 18. Initializing the NVIC is less clear. It actually seems to duplicate the counter initializations.

Lots of questions, but the first is how do I initialize the interrupt structure so that the INTERRUPT SUB is vectored from that particular Exception 18? I assume from your examples that I need to initialize a bunch of registers to enable, acknowledge and clear that specific interrupt, but the details seem to be cloaked in C structures beyond my comprehension. Is there a simple set of steps for handling interrupts on the M0 platform?



basicchip
Posts: 813
Joined: Fri Oct 19, 2012 2:39 am
Location: Lake Tahoe, CA
Contact:

Re: LPC1114 Low Power Experimenting

Post by basicchip » Sun Feb 17, 2013 1:41 am

Take a look at the TIMER1.bas in the Program Files (x86)/Coridium/BASIClib/Interrupts

If it is not there, you should update your tools. It shows how to setup an interrupt for 2 seconds.

armnewbee
Posts: 3
Joined: Fri Feb 15, 2013 11:34 pm

Re: LPC1114 Low Power Experimenting

Post by armnewbee » Sun Feb 17, 2013 4:20 pm

Thanks! I was working with an older example from the LPC21xx and struggling with the differences in the VIC structure. The timed interrupts are working great now!

Now, the question of entering sleep mode from BASIC. Do I need to create an assembly code subroutine using WFI? I vaguely remember reading online in an old post of an ASM() command, but I do not see any documentation in the ARMbasic help files or online. Or is there another way to initiate sleep strictly via BASIC software control?

basicchip
Posts: 813
Joined: Fri Oct 19, 2012 2:39 am
Location: Lake Tahoe, CA
Contact:

Re: LPC1114 Low Power Experimenting

Post by basicchip » Sun Feb 17, 2013 9:09 pm

Good point, had not thought about that, we can create a WFI with just a compiler change, though I'll have to check that firmware recovers gracefully.

basicchip
Posts: 813
Joined: Fri Oct 19, 2012 2:39 am
Location: Lake Tahoe, CA
Contact:

Re: LPC1114 Low Power Experimenting

Post by basicchip » Sun Feb 17, 2013 10:55 pm

Below is a version of the compiler that allows a SLEEP command which emits a WFI into the code (at least for Cortex parts). And also an example of using TIMER1 interrupt to wake it up.

The normal WFI, does what it says, and acts like the code is looping waiting for an interrupt. But some deep sleep and deep power down states, restart as if a reset occurs (the CPU state is not maintained). I haven't tested those, and would be interested to know if it works for those.
Attachments
SLEEP.bas
Use of SLEEP in BASIC program
(1.51 KiB) Downloaded 415 times
ARMbasic.exe
ARMbasic compiler 8.20a
(112.92 KiB) Downloaded 358 times

armnewbee
Posts: 3
Joined: Fri Feb 15, 2013 11:34 pm

Re: LPC1114 Low Power Experimenting

Post by armnewbee » Mon Feb 18, 2013 11:33 pm

Wow! That was quick service. It works great for sleep mode. Next step is to investigate optimized sleep or deep sleep, since sleep only took my BasicChip down to about 7 mA. I see a lot of documentation on sleep optimization, so thanks for your help getting this far. I'm very happy with both the BasicChip and the SuperPro+.

One thing...I noticed that the LPC11xx.bas file changed many of the register names from my earlier version. That caught me by surprise. I understand that the BasicChip is new and still being refined - so changes are expected. Do you publish any release notes or change notes we can review?

basicchip
Posts: 813
Joined: Fri Oct 19, 2012 2:39 am
Location: Lake Tahoe, CA
Contact:

Re: LPC1114 Low Power Experimenting

Post by basicchip » Wed Feb 20, 2013 1:54 am

We try not to change names, and don't do it arbitrarily.

Much of those were to make them more consistent with the other parts, which we found when writing some of the example programs, which run across all the chips that have appropriate hardware.

Post Reply