Hello, i am using PIC16F876A microcontroller. I am trying to put microcontroller in sleep mode to reduce power consumption. Generally my program's structure is:
In the beginning program must initialise LCD, variables in RAM, microcontroller ports etc. This must be onlyon first turn on of microcontroller. After that the FOR statement begins (endless loop, in which microcontroller tests mains supply voltage presence. If blackout occured (there is level 1 on PORTB RB7 input) microcontroller must go to sleep mode. Wake up must occur on TMR1 interrupt. My question is: where the program will be executed wake up from sleep? I thought that program after interrupt will execute next line after sleep command. But in my case program after wake up from sleep returns in the very begining - initialisation. Maybe on sleep RAM goes to unknown state?
Rich (BB code):
void interrupt (){some code here}
void main()
{initialisation of ports, LCD, etc.;
for (;;)
{some code here;
if(PORTB.B7==1){asm{sleep
nop
}
}
some code here;
}
}