Hey there, if you want, you can try JALv2 & Jallib at www.justanotherlanguage.org. There is a getting started guide there. You will see that the code syntax is easy to read and write. There is full support for I2C with sample files ready to use (just burn them to your PIC), and there is a i2c slave tutorial: http://www.justanotherlanguage.org/content/tutorial_peripherals Matt. > Date: Fri, 15 Jan 2010 19:07:04 +0000 > Subject: [PIC]: Unable to read PORTB Bit 4, I'm doing something wrong.. > From: gordond1980@googlemail.com > To: piclist@mit.edu > > Hi All, > > I'm very new to PIC's and have started a small project where I want > the PIC18 to be an I2C slave. I am prototyping my design on the PICKit > 2 Low Pin Count Board with only the modifications described here. > > PIC : PIC18F13K22 and PIC16F690 (Obviously with different code / toolchain) > Tool Chain : C18 with MPLAB > > Problem : > > I was unable to get the I2C Slave HW to Ack address bytes sent by an > Aardvark USB to I2C and after a week went back to basics. On the > prototype board I have removed the I2C connection (no other components > / connections) and Pulled RB4 and RB6 High via 33K resistors. I have > verified 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 > is high. It does not matter which bit I read first. I've swapped out > to a different Chip and also switch to a different variant (PIC16F690) > and re written the code below accordingly all with the same result so > I'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 > void 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; > } > } > > > I am stumped. Any help / pointers gratefully received. > > Many thanks, > Gordon > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://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