#include<msp430f135.h>
#define LED1 BIT0
#define SCL BIT6
#define SDA BIT7 //serial Address/Data I/O
void Init_I2C_eeprom(void);
void I2C_Start_bit(void);
/*
void I2C_write_byte_eeprom(unsigned char Byte);
int I2C_send_Ack(void);
void I2C_Stop_bit(void);
*/
void delay(void);
void main(void)
{
//unsigned char RxData = 0;
//Config_timer();
Init_I2C_eeprom(); //Initilise I2C
I2C_Start_bit(); //Start bit
// I2C_write_byte_eeprom(0xA0); //write the byte into EEPROM(Slave)
// I2C_send_Ack(); //ACK after tranmitt data
// I2C_Stop_bit(); //Stop bit
_BIS_SR(GIE); // Enter LPM0 w/ interrupt
}
void Init_I2C_eeprom(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog
P1DIR |= 0x01; // Set P1.0 to output direction
P1OUT |= 0x01;
BCSCTL1 |= RSEL2;
DCOCTL |= DCO1 + DCO0; // by both above two statement Means it will generate 1MHz Internal DCO frequency
//P4SEL = 0x00; //(Not needed in this program)All port P4 pin is selected as GPIO
//SDA lines can be input or output
//Make SDA and SCL lines input intially (if Master is receving(reading) data from slave)
P4DIR |= 0xf0; // Serial Clk line (SCL) selected as input
//P4DIR |= 0x80; // Serial Data line (SDA) selected as input
P4OUT |= 0xf0;
//P4OUT |= 0x80;
//P4IN &= 0x0040;
//P4IN &= 0x0080;
SCL = 1;
SDA = 1;
}
void I2C_Start_bit(void)
{
SCL = 1; //Make SCL pin high//high to low transition while SCL = 1
SDA = 1; //Make SDA pin high
delay(); //for high to low transition
SDA = 1; //Make SDA pin low
delay();
}
void delay(void)
{
unsigned char i;
for(i=0;i<20;i++);
}