Tiwana6330
Member level 1
I am using PIC18LF1220. The output functions (on PortA) work fine, however, the input functions on PortB are not working. I have checked hardware connections to Pin and they are fine. I think I am missing something in the code. My code is as below.
Can anyone point what is wrong? Have I missed setting some register? thanks for your help
Code:
#include <hitech.h>
#include <stdio.h>
#include <pic18.h>
#include "delay.c"
#define _XTAL_FREQ 20000000 //20Mhz
void main (void)
{
ADCON0 = 0x00;
ADCON1 = 0x0F; // Configure all ports with analog function as digital INTCON=0;
TRISA=0;
TRISB=255;
PORTA=0;
while (1)
{
if (RB1==0)
RA1=1;
else
RA1=0;
}
Can anyone point what is wrong? Have I missed setting some register? thanks for your help