View previous topic :: View next topic |
Author |
Message |
JimB
Joined: 25 Aug 2005 Posts: 65 Location: Huntington Beach, CA
|
Options for waking up a 16LF877A while in sleep() mode? |
Posted: Thu Oct 12, 2006 1:32 pm |
|
|
I am using the 16LF877A device in my project. I have a single pushbutton going to pin 24 (RA2). I have a square wave signal generated by the micro, fed back to pin 8 (RB0/INT). Now I want to use the processors "sleep()" feature, but from what I am able to determine, the only way to wake the processor is to use the RBO/INT or use the MCLR. I assume the latter would reset the software to start all over, which I do not want. Since the square wave starts when the pushbutton is pushed is there another way to awaken the processor?
Also I could not find a spec on the processors current draw during sleep mode. Is there a significant drop in current? The project manager doesn't want to have an ON/Off switch if possible. The entire circuit now draws 19mA when no square wave is running since I disable most of the rest of the electronics, except for the crystal oscillator which only draws a couple of mA except for when the button is pushed, the square starts and all other devices are enabled as needed. These are an RS232 chip, negative voltage generator and 6 opamps. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Oct 12, 2006 1:39 pm |
|
|
Quote: | I could not find a spec on the processors current draw during sleep mode |
Download the 16F877A data sheet.
http://ww1.microchip.com/downloads/en/DeviceDoc/39582b.pdf
Look on page 179 (in the Acrobat reader), at this chart:
Quote: |
17.1 DC Characteristics:
Power-down Current |
|
|
|
Mattr0
Joined: 27 Mar 2005 Posts: 30
|
|
Posted: Fri Oct 13, 2006 10:21 am |
|
|
you could use the watchdog timer to wake up the micro every so often to check you push button. You will sacrifice you sleep current a bit though |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Fri Oct 13, 2006 10:22 am |
|
|
If its only sleeping lightly, how about an alarm clock? _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Guest
|
|
Posted: Sat Oct 14, 2006 3:53 pm |
|
|
Since I am generating the square wave with the micro's "CCP1" output and feeding it back to RB0/INT to trip the L to H edge flag, could there be a way to set this flag internally, i.e. without an external path to the external interrupt? This would leave the RBO/INT input available for triggering the "wake" function. I'm just not experienced enough to determine this. |
|
|
Mattr0
Joined: 27 Mar 2005 Posts: 30
|
|
Posted: Sat Oct 14, 2006 4:08 pm |
|
|
you should look at RB4 - RB7. These pins can be configured to create an interupt on there state change this should wake up the micro. |
|
|
Ttelmah Guest
|
|
Posted: Sun Oct 15, 2006 3:03 am |
|
|
Anonymous wrote: | Since I am generating the square wave with the micro's "CCP1" output and feeding it back to RB0/INT to trip the L to H edge flag, could there be a way to set this flag internally, i.e. without an external path to the external interrupt? This would leave the RBO/INT input available for triggering the "wake" function. I'm just not experienced enough to determine this. |
OK. So you are running Timer1, presumably using an external clock?. If not, it'll stop when the processor goes to sleep. You don't need the feedback connection. All you do, is disable global interrupts (you don't want an interrupt 'handler' to be called), clear the CCP1 interrupt (it'll already be set from the last cycle of the clock), and enable the CCP1 interrupt. Then go to sleep. The CCP interrupt bit, will be set, when the CCP 'count' matches, and the chip will wake up. Preferably put a 'nop' instruction after the sleep (delay_cycles(1)), snce the next instruction is 'prefectched' when the processor goes to sleep, and if it is something like a 'test' instruction, will not execute as expected.
Code: |
disable_interrupts(GLOBAL);
//also disable any other individual interrupts that you do not
//want to wake the chip here.
enable_interrupts(INT_CCP1);
clear_interrupts(INT_CCP1);
sleep();
delay_cycles(1); //dummy instruction after sleep
disable_interrupts(INT_CCP1);
//If you want to use other interrupts in the main code, re-enable them
//here, and enable the 'GLOBAL' flag.
|
Best Wishes |
|
|
JimB
Joined: 25 Aug 2005 Posts: 65 Location: Huntington Beach, CA
|
|
Posted: Fri Oct 20, 2006 2:57 pm |
|
|
I think that there is information here that will help me, but some clarification is needed. From the previous help statements, I think that it is being assumed that the CCP1 timer runs all the time, which it doesn't.
The CCP1 output square wave that I now have fed back to RBO/INT only runs when I use the pushbutton. The button push turns on the oscillator, a bunch of external electronics and runs until enough data is taken, then it stops and waits for another push of the button. I used the RBO/INT to generate the external L to H edge interrupt flag which starts a delay time and then tells the A/D to read the data at a fixed time after the L to H edge occurs. Since the square wave signal is generated in the micro perhaps this L to H edge setting of the interrupt flag may be internally accessable without using the RBO/INT pin and I can then use it to wake up the micro. It is this intertal access to the L to H edge flag that I don't know whether it is possible to do or not. It would also be desireable to use the same pushbutton for the wake up and also run the device. |
|
|
|