Tiwana6330
Member level 1
- Joined
- Feb 3, 2011
- Messages
- 36
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,288
- Activity points
- 1,536
Hi. I have run into a strange problem. I am using PIC18LF1220. The microcontroller is working fine except pin RB2. I have configured RB2 as input but it always reads 0 volts. To eliminate possibility of (hardare) PCB problem, I bent the RB2 pin so now its not touching the PCB. Then I am applying 3.3 volt directly from power supply to the pin. However, the pin is not registering that as high. I have also tried changing the chip. Code is below
note that other pin on PortB (RB0) is working fine as input
Can anyone please help. I think I am missing something in config bits
Code:
#include <hitech.h>
#include <pic18.h>
void main (void)
{
ADCON0 = 0x00;
ADCON1 = 0x7F; // 7F Configure all ports with analog function as digital
INTCON=0;
TRISB = 0b11111111; //makes Bport input
TRISA = 0b00000000; //makes A port output
PORTA=0;
while (1)
{
if (RB2==1)
RA0=1;
else
RA0=0;
}
}
note that other pin on PortB (RB0) is working fine as input
Can anyone please help. I think I am missing something in config bits