i2c on 18F

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
I want to implement i2c on an multimaster/slave environment.
This is the first time I implement i2c myself and I found that the
application notes from Microchip doesn't show in a simple manner how to
implement this on an 18F, they have a whole bunch of notes for 16F.

I thought to write routines that handle everything and that I would have
only a few variables to worry about in the rest of the code.

set the i2caddr, i2cdata, bytes and call send
poll the i2cstatus byte for a received byte and handle it

that should be almost everything I want in the main program.
The PIC's will be in slave mode unless they're sending

There will (not yet) been asked to read a byte from an S-EEPROM.
But there might be a global call (broadcast) to all devices.

Can anybody help me get some could tutorials or (example) code for this

ThanX,

Alexander
ThanX



Re: i2c on 18F
Hi Alexander

Have adapted some 16F code to 18F code for Master & Slave.

I have tested the code in MPLAB but not in actual chips at this time.

Will test in chips as soon as I can.

Do you want me to email the code to you  for now? or what until I have
tested it on some chips?




Re: i2c on 18F
Hi Alexander

Have programmed the master & slave code I sent you into PIC chips but at
this stage the master is only sending the "Write Start" and not going any
further, guess it has not found the I2C bus or somthing - am investigating
now.

Just let you know incase you had the same problem.

Roy



Re: i2c on 18F


Hey Roy and Alexander

I have been working with both a 18F452 and 16F877, with the 18F452 as
a master and the 16F877 as the slave. As of now I have been able to
get the 18F452 to easily transmit the start bit address and when
debugging and forcing the SDA low for an acknowlege from a slave the
18F452 even starts sending the required data along the SDA. I found
getting the 18F452 to transmit on the I2C bus quite easy in the end,
the only problem I am having is getting the 16F452 to receive the
data. Maybe one of you could help me out with this, or maybe I could
help you out with your problems to? It is really starting to get to me
now, I just can''t understand wy my 16F452 doesn't accept the data in
slave mode. Like yourselves I have found code for the 16f452 but it
all seems to be for master mode, and the slave mode code i have found
seems to have bugs in it that i can't figure out. Hope we can all work
something out here so as we can get our systems to function correctly.

Cheers

Robert

Quoted text here. Click to load it

Re: i2c on 18F


Robert

I have been been side lined while building an ICD2 clone.

If you don't mind can you update me on how your I2C program is getting on.

I would like to see your code if it is in assembler, if you don't mind can
you email it to me at snipped-for-privacy@ihug.co.nz

thanks in advance.



Site Timeline