Hi..
I'm having a tiny bit of problem here.. What I'm tryhing to do is just basic stuff but I couldn't understand why it isn't working.. I'm using PIC12F615.
What I plan to do is these:
1) when GP2 is HIGH, go into sleep mode.
2) when GP4 is pressed, wakeup from sleep (interrupt-on-change) and turn LED at GP1 HIGH/LOW
However, what I found is these:
1) It did not go into SLEEP mode when GP2 is HIGH. Infact, it didn't even recognize that GP2 is HIGH.
2) It also did not recognize that GP4 is HIGH and because of that, GP1 is always LOW.
Below is the code.. I simulate using MPLAB SIM. Did I overlook something..? Please help.. Thanks..
I'm having a tiny bit of problem here.. What I'm tryhing to do is just basic stuff but I couldn't understand why it isn't working.. I'm using PIC12F615.
What I plan to do is these:
1) when GP2 is HIGH, go into sleep mode.
2) when GP4 is pressed, wakeup from sleep (interrupt-on-change) and turn LED at GP1 HIGH/LOW
However, what I found is these:
1) It did not go into SLEEP mode when GP2 is HIGH. Infact, it didn't even recognize that GP2 is HIGH.
2) It also did not recognize that GP4 is HIGH and because of that, GP1 is always LOW.
Below is the code.. I simulate using MPLAB SIM. Did I overlook something..? Please help.. Thanks..
Code:
#include <pic.h>
__CONFIG(INTIO & OSC_8MHZ & WDTDIS & PWRTEN & MCLRDIS & UNPROTECT & BOREN);
void interrupt isr(void)
{
if (GPIF == 1)
GPIF = 0;
}
main()
{
TRISIO4 = 1;
TRISIO1 = 0;
TRISIO2 = 1;
IOC4 = 1;
GPIE = 1;
ei();
while(1)
{
if (GP4==1)
GP1 = 1;
else
GP1 = 0;
if (GP2==1)
SLEEP();
}
}