I2C communication problems with EEPROM
Posted: Fri Sep 14, 2012 12:22 pm
Hello
I have tried to get i2c communication work with EEPROM. I have Easy PIC development board with 18f45k22 PIC installed
I have tried both the transmit and transaction components, but it doesnt work. In transmit mode I get ACK messages after every command, but the data from EEPROM in not valid, i get 255 in every case.( I dont know if its transfering at all), I think the PIC cant read the EEPROM now
I have also same problem with Modtronix SBC83IL board, the data doesnt transfer. I have tried many methods and also checked the EEPROM address is correct.
Here is mikroC Pro c code which works fine: ( when I made similar program with flowcode, it doesnt work.)
void main(){
ANSELB = 0; // Configure PORTB pins as digital
ANSELC = 0; // Configure PORTC pins as digital
TRISB = 0; // Configure PORTB as output
LATB = 0; // Clear PORTB
I2C1_Init(100000); // initialize I2C communication
I2C1_Start(); // issue I2C start signal
I2C1_Wr(0xA2); // send byte via I2C (device address + W)
I2C1_Wr(2); // send byte (address of EEPROM location)
I2C1_Wr(0xAA); // send data (data to be written)
I2C1_Stop(); // issue I2C stop signal
Delay_100ms();
I2C1_Start(); // issue I2C start signal
I2C1_Wr(0xA2); // send byte via I2C (device address + W)
I2C1_Wr(2); // send byte (data address)
I2C1_Repeated_Start(); // issue I2C signal repeated start
I2C1_Wr(0xA3); // send byte (device address + R)
LATB = I2C1_Rd(0u); // Read the data (NO acknowledge)
I2C1_Stop(); // issue I2C stop signal
}
I have tried to get i2c communication work with EEPROM. I have Easy PIC development board with 18f45k22 PIC installed
I have tried both the transmit and transaction components, but it doesnt work. In transmit mode I get ACK messages after every command, but the data from EEPROM in not valid, i get 255 in every case.( I dont know if its transfering at all), I think the PIC cant read the EEPROM now
I have also same problem with Modtronix SBC83IL board, the data doesnt transfer. I have tried many methods and also checked the EEPROM address is correct.
Here is mikroC Pro c code which works fine: ( when I made similar program with flowcode, it doesnt work.)
void main(){
ANSELB = 0; // Configure PORTB pins as digital
ANSELC = 0; // Configure PORTC pins as digital
TRISB = 0; // Configure PORTB as output
LATB = 0; // Clear PORTB
I2C1_Init(100000); // initialize I2C communication
I2C1_Start(); // issue I2C start signal
I2C1_Wr(0xA2); // send byte via I2C (device address + W)
I2C1_Wr(2); // send byte (address of EEPROM location)
I2C1_Wr(0xAA); // send data (data to be written)
I2C1_Stop(); // issue I2C stop signal
Delay_100ms();
I2C1_Start(); // issue I2C start signal
I2C1_Wr(0xA2); // send byte via I2C (device address + W)
I2C1_Wr(2); // send byte (data address)
I2C1_Repeated_Start(); // issue I2C signal repeated start
I2C1_Wr(0xA3); // send byte (device address + R)
LATB = I2C1_Rd(0u); // Read the data (NO acknowledge)
I2C1_Stop(); // issue I2C stop signal
}