Try adding the following lines to your Init section: ANSEL = 0x00; ANSELH = 0x00; -----Original Message----- From: Gordon Downie To: piclist@mit.edu Sent: Fri, Jan 15, 2010 1:07 pm Subject: [PIC]: Unable to read PORTB Bit 4, I'm doing something wrong.. Hi All, I'm very new to PIC's and have started a small project where I want he PIC18 to be an I2C slave. I am prototyping my design on the PICKit Low Pin Count Board with only the modifications described here. PIC : PIC18F13K22 and PIC16F690 (Obviously with different code / toolchain) ool Chain : C18 with MPLAB Problem : I was unable to get the I2C Slave HW to Ack address bytes sent by an ardvark USB to I2C and after a week went back to basics. On the rototype board I have removed the I2C connection (no other components connections) and Pulled RB4 and RB6 High via 33K resistors. I have erified the resistance and voltage at the pin and both are correct 4.9v and 33kohm to Vdd), however when I read the port bits only RB6 s high. It does not matter which bit I read first. I've swapped out o a different Chip and also switch to a different variant (PIC16F690) nd re written the code below accordingly all with the same result so 'm confident I have missed something rather than a bad chip / board. #include /* for TRIS and PORT declarations */ #pragma config WDTEN = OFF pragma config FOSC = IRCCLKOUT pragma config PLLEN = ON pragma config PCLKEN = ON #pragma config MCLRE = OFF pragma config LVP = OFF pragma code oid main (void){ unsigned int b = 0; // OSC OSCCON = 0b11111100; // 8 MHz internal oscillator TRISC = 0x0; TRISB = 0xFF; PORTC = 0; TRISBbits.TRISB4 = 1; TRISBbits.TRISB6 = 1; while(1){ //Display RB4 / RB6 on PORTC LATCbits.LATC0 = PORTBbits.RB4; LATCbits.LATC1 = PORTBbits.RB6; //Heartbeat b++; if (b==0) LATCbits.LATC3 = !LATCbits.LATC3; } am stumped. Any help / pointers gratefully received. Many thanks, ordon - ttp://www.piclist.com PIC/SX FAQ & list archive iew/change your membership options at ttp://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist