PDA

View Full Version : Setting up Port b for I2C on 18f2550



rjones2102
- 2nd October 2007, 18:27
Hi all,

I am learning how to use a datasheet but it is hard going! I have just learnt ADCON1=15 switches all the A/D conversion off and makes all pins digital. Great. I understand controlling port direction with TRIS register and how to disable A/D. Very useful in the Pic world as I now understand it!

What I want to know is when I use the PICs designated pins for SDA and SCL do I need to disable the hardware feature of I2C because as I understand it I2C comms is handled in software in PBP.

I read in the datasheet that SDA pin can affect the baud rate generator on reset. I have a problem with garbage coming out of TX pin when I ICSP my chip since I have hooked up SDA/SCL to EEPROM. Then HSEROUT behaves erratically for the first couple of uses. Very unpredictable. Do I need to set anything in SSPEN? Would it be better to use different pins if I2C is handled in software?

So in summary, I have made the pins digital with ADCON1=15. I have TRISB=%0000001 as I believe SCL is an output but what do I set SDA to as it is bi-directional? Is there anything else I need to do?

I must go to bed, this is too exciting and it's 3.30AM!!

Thanks

Rich

mister_e
- 2nd October 2007, 20:22
Using I2CREAD/I2CWRITE allow you to use whatever I/O you want to. If you plan to use the internal MSSP module, none of the native PBP statement will help.

If you can, post your code here. Maybe you just need to disable the on-board MSSP.

As long as you don't need the MSSP speed, I2CREAD/I2CWRITE work just fine.