![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
mcafzap
Joined: 07 Sep 2003 Posts: 46 Location: Manchester, UK
|
PIC10F206 loses data after sleep? |
Posted: Thu Mar 10, 2005 3:10 pm |
|
|
I have a problem where I put the PIC to sleep, but only want it to do anything one third of the time. With the 12F629 this is no problem, so I'm beginning to suspect the 10F...
Code: |
#include <10F206.h>
#Fuses NOMCLR,NOPROTECT,WDT
#use delay(clock=4000000)
#use fast_io(B)
void shortbeep(void);
void initialise(void);
#byte GPIO = 6
#bit GP0= GPIO.0
#bit GP1= GPIO.1
#bit GP2= GPIO.2
#bit GP3= GPIO.3
#byte CMCON0 = 0x07
#bit CMPOUT = CMCON0.7
int8 count;
void main() {
initialise();
While(1){
if (CMPOUT){ // Outside apparently...
if (count > 2) {
shortbeep(); //beep if required.
count = 0;
}
}
sleep();
initialise();
count++;
}
} //end main
//******************************* end main program *************************************
void initialise(void) {
GPIO = 0x00;
#asm
movlw 0x09 //Bits 0 & 3 inputs
TRIS GPIO
// Disable wake-up on pin change, enable weak pull-ups,
// Timer0 source internal, L to H
// Prescaler to WDT, max division 2304mS
movlw 0x8F
OPTION
#endasm
// no comparator output,
CMCON0 = 0x7B;
}
// Piezo element on GPIO bits 0 and 1
void shortbeep(void)
{
int8 t, j;
t = GPIO & 0x09;
for(j=0; j<=250;j++)
{
GPIO = t | 0x02;
Delay_Us(120);
GPIO = t | 0x04;
Delay_Us(110);
}
GPIO = t;
}
|
Now if I remove the
All is well, suggesting a loss of data from sleep period to sleep period. The supply is fairly heavily decoupled with a 1uF ceramic right under the PIC, along with a 100uF Al electrolitic.
Am I doing something particularly stupid that one of you can spot?
FWIW the compiler is version 3.206
Steve |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 10, 2005 3:52 pm |
|
|
The "wake-up from sleep" behavior is different between the two devices.
Compare the data sheets in that area. |
|
![](templates/subSilver/images/spacer.gif) |
mcafzap
Joined: 07 Sep 2003 Posts: 46 Location: Manchester, UK
|
|
Posted: Thu Mar 10, 2005 4:49 pm |
|
|
Good thinking PCM, thank-you.
For anyone's interest, the 10F series generates a standard reset on watchdog timeout whether or not it is in sleep mode, this means that the line
will never be executed.
In fact because of this behaviour the code can be simplified: remove the while(1) loop because the of the hidden 'SLEEP' instruction, initialise() need only be in line since it too would not be reached.
Steve |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|