i2c on 18F

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

Reply to
Alexander
Loading thread data ...

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?

Reply to
Hopkins

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

Reply to
Hopkins

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

Reply to
Robert

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.

Reply to
Hopkins

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.