Page 1 of 1

LPC1114 Low Power Experimenting

Posted: Sat Feb 16, 2013 12:11 am
by armnewbee
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?

Re: LPC1114 Low Power Experimenting

Posted: Sun Feb 17, 2013 1:41 am
by basicchip
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.

Re: LPC1114 Low Power Experimenting

Posted: Sun Feb 17, 2013 4:20 pm
by armnewbee
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?

Re: LPC1114 Low Power Experimenting

Posted: Sun Feb 17, 2013 9:09 pm
by basicchip
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.

Re: LPC1114 Low Power Experimenting

Posted: Sun Feb 17, 2013 10:55 pm
by basicchip
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.

Re: LPC1114 Low Power Experimenting

Posted: Mon Feb 18, 2013 11:33 pm
by armnewbee
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?

Re: LPC1114 Low Power Experimenting

Posted: Wed Feb 20, 2013 1:54 am
by basicchip
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.