td micro
Member level 5
hi..
i write one program to identify the switch pressed, which is connected to pic 18f port B0. when switch is pressed,it is connected to ground. but i m not getting the proper output.. USART communication is ok... here is my code..
void main(void)
{
int x;
TRISB=1;
LATB=1;
INTCON2bits.RBPU=0; //enable pull up
WPUBbits.WPUB0=1;
ANSELH=0x00;
EnableUART();
printf("plz press key");
while(1)
{
x=LATBbits.LATB0 ;
if (x==0)
printf("key pressed");
}
}
plz plz help me to solve this..
i write one program to identify the switch pressed, which is connected to pic 18f port B0. when switch is pressed,it is connected to ground. but i m not getting the proper output.. USART communication is ok... here is my code..
void main(void)
{
int x;
TRISB=1;
LATB=1;
INTCON2bits.RBPU=0; //enable pull up
WPUBbits.WPUB0=1;
ANSELH=0x00;
EnableUART();
printf("plz press key");
while(1)
{
x=LATBbits.LATB0 ;
if (x==0)
printf("key pressed");
}
}
plz plz help me to solve this..