Maker Pro
Maker Pro

I2C interface HELP

lmoraxs

Nov 19, 2009
1
Joined
Nov 19, 2009
Messages
1
I am trying to interface a MASTER PIC with a SLAVE PIC using PIC18F2420 for both master and slave. I have played around with my code so much but when i simulate it i dont seem to get the results i expect. I have used the header files provided by microchips MCC18 compiler for the pic and I2c. I am trying to write a very simple program for the master pic telling the slave pic to output a string of zero's and one's that will light up LED's accordingly. The source code is given below:

#include <p18f2420.h>
#include <I2c.h>
#define SLAVE_7_STSP_INT 0b00001110
#pragma config OSC = INTIO67

//unsigned char counter;
void initialisePorts (void)
{
TRISC = 0b10011000; //I2c bits set

}
void main (void)
{
OpenI2C ( MASTER, SLEW_ON ); //intialise 12C
SSPADD = 0x63; // set up baud rate


StartI2C (); //send start condition
WriteI2C (SLAVE_7_STSP_INT); // write to address (slave pic)
while (1) {
//I2C_SDA
//I2C_SDA


//for (counter = 0; counter <= 10; counter++)
WriteI2C ();

TRISCbits.TRISC4 = 0b11111111; //output to SDA
TRISCbits.TRISC4 = 0b10000001;

}



StopI2C ();
}

Can anyone please show me wher i am going wrong. My ultimate aim is to interface a SE95 temperatue sensor with the master pic via the i2c bus but i belive once i can get this to work that should be easy. Thank you.
 
Top