Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

P18f4550 i2c and ST

Status
Not open for further replies.

rk396

New Member
Ok, i'm at the end of my rope on this one. I'm like 1 step past beginner here.

Im trying to interface a p18f4550 to an eeprom vie I2C. The routines hang on the wait for ACK from the slave.

I've tried teh built in I2c functions, software functions from C18. I have written my own, and tried various routines i've found on the internet.

the problem. PortB.RB1 is NOT acting like a schmitt trigger input.

I slowed down the transmit function my adding some delays, and hooked up a Powered LED to each PortB 0, and 1. PortB.0 acts accordingly basically lights on a 0, and is off on a 1. Porb.1... nothign. If i switch the def for the clock and data, meaning portB.0 is now the clock. it pulses as expected, and the data line shows nothing.

a crude way to debug i know.

I've configured portb to be all digital thru the config bits and thru the Adcon2.

Am i missing somehting? I can post code if necessary. is the clock supposed to act like an ST or just as an output? All the docs that i found state that both SDA and SCL should be ST's with a pull up resistor (which i have ~10k).

I hope someone can point out the thing that i'm missing.

thanks
 
Last edited:
Which functions are you using.. Usually this works straight off the bat... Are you using ANY interrupts atall? In C18's example they switch back on the interrupts too early, I modified the code slightly to make it work.

You will need to change the port and processor speed.
 

Attachments

  • Myi2c.zip
    1.5 KB · Views: 117
Ian,

Thanks for the quick reply. Also thanks for the code... i'll give it a try.

I would have thought it should work right out of the box too... i'm sure it's something simple i'm missing. I am not using any interupts in my current version. I tried the software version, and the hardware version that comes with the C18 compiler. I'm off to try your code. thanks again.
 
ok, the routines worked THANK YOU very much.

At first glance they look like the ones i was using, not sure what my deal was. just glad it's now working.
 
Status
Not open for further replies.
Back
Top