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?
LPC1114 Low Power Experimenting
Re: LPC1114 Low Power Experimenting
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.
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
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?
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
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
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.
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 1324 times
-
- ARMbasic.exe
- ARMbasic compiler 8.20a
- (112.92 KiB) Downloaded 1245 times
Re: LPC1114 Low Power Experimenting
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?
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
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.
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.