I am quite new to PICs programming and I want to make my PIC12F683 wake-up from sleep if 5 V (+) is feed to Pin 2.
I wrote the code (mikroC PRO v 6.0.0) below but it is not working on my PIC12F683. I am able to compile and write the code to the PIC but it does not wake-up from sleep.
Code: Select all
void main() // Blink a LED after wake-up from sleep (PIC12F683)
{
int ctr;
TRISIO.B2 = 0; // Set Pin 5 as Output
TRISIO.B5 = 1; // Set Pin 2 as Input
INTCON.GIE = 1; // Enable Global Interrupt
IOC.B5 = 1; // Enable interrupt-on-change on Pin 2
asm{sleep}; // Make PIC12F683 sleep
// When 5v (+) is fed to Pin 2, the PIC should wake up
// and run the For Loop
for(ctr=1;ctr<=5;ctr++) // Blink a LED
{
GPIO.B2 = 1;
Delay_ms(500);
GPIO.B2 = 0;
Delay_ms(500);
}
}
Thanks.
Dan07