Electronics Forums

Electronics Forums > Electronics Forums > Microcontrollers and Programming > I2C interface HELP

Reply
Thread Tools Display Modes

I2C interface HELP

 
 
Junior Member
Join Date: Nov 2009
Posts: 1
 
      11-19-2009, 10:47 PM
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Need Help With PC Hardware Interface Project. Rich Grise Electronic Basics 1 12-21-2005 12:23 PM
interface real world to pc question? russ Electronic Basics 6 07-16-2005 11:18 PM
Looking for source of chip or chipset for Serial ATA interface F;,VN[OWIR Electronic Components 2 06-24-2004 06:04 AM
Re: ADC with I2C interface Dan Dunphy Electronic Components 0 04-04-2004 02:29 AM
Re: ADC with I2C interface starfire Electronic Components 0 04-01-2004 12:26 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93