This is to initialize
Void key_Init ()//unsigned char Set_EC11_TYPE)
{
//LATC2=0;
//RB4=1;
TRISB4=1;//input
ANSB4=1;//RC2=0;
//LATB4=0;
//WPUB4=1;
//ODCB4=1;
//SLRB4=1;
//INLVLB4=0;
//RC2=1;
TRISC2=1;//input
ANSC2=1;
LATC2=0;
WPUC2=0;
//ODCC2=1;
//SLRC2=1;
//INLVLC2=0;
//
GIE=1;//open all interrupt
PEIE=1;//the open PHER int
IOCIE=1;
IOCIF=0;
//IOCMD=1;
IOCBP4=0;
IOCBN4=1;//fall RB4
//IOCBF4=0; The enable interrupt flag
INTPPS=0 x0c;
}
This is the interrupt service function
If (IOCBF4 & amp; & IOCIE & amp; & IOCIF)
{
IOCBF4=0;
If (RB4==1)
{
If (RC2==1)
{
count++;
}
The else
{
The count -;
}
}
IOCIF=0;
}
CodePudding user response:
Everyone a great god for help