sreepss
Full Member level 4
- Joined
- Jun 10, 2009
- Messages
- 204
- Helped
- 29
- Reputation
- 60
- Reaction score
- 27
- Trophy points
- 1,308
- Location
- Cochin, Kerala, India
- Activity points
- 2,376
Hai all I encounter a problem during the I2c Operation. Iam using the MikroC compailer but thei2c operation does not works.
aim using the EEPROM 24C256 and a PIC16F877 as controller.
the I2c Bus reads only 255 after the writing process (In Proteus Simulator);
Pls help me in this problem..
iam using the example code in Mikro C
---------- Post added at 07:52 ---------- Previous post was at 07:48 ----------
the code was void main(){
PORTB = 0;
TRISB = 0;
I2C_Init(100000);
I2C_Start(); // Issue I2C start signal
I2C_Wr(0xA2); // Send byte via I2C (command to 24cO2)
I2C_Wr(2); // Send byte (address of EEPROM location)
I2C_Wr(0xF0); // Send data (data to be written)
I2C_Stop();
Delay_ms(100);
I2C_Start(); // Issue I2C start signal
I2C_Wr(0xA2); // Send byte via I2C (device address + W)
I2C_Wr(2); // Send byte (data address)
I2C_Repeated_Start(); // Issue I2C signal repeated start
I2C_Wr(0xA3); // Send byte (device address + R)
PORTB = I2C_Rd(0u); // Read the data (NO acknowledge)
I2C_Stop();
}
aim using the EEPROM 24C256 and a PIC16F877 as controller.
the I2c Bus reads only 255 after the writing process (In Proteus Simulator);
Pls help me in this problem..
iam using the example code in Mikro C
---------- Post added at 07:52 ---------- Previous post was at 07:48 ----------
the code was void main(){
PORTB = 0;
TRISB = 0;
I2C_Init(100000);
I2C_Start(); // Issue I2C start signal
I2C_Wr(0xA2); // Send byte via I2C (command to 24cO2)
I2C_Wr(2); // Send byte (address of EEPROM location)
I2C_Wr(0xF0); // Send data (data to be written)
I2C_Stop();
Delay_ms(100);
I2C_Start(); // Issue I2C start signal
I2C_Wr(0xA2); // Send byte via I2C (device address + W)
I2C_Wr(2); // Send byte (data address)
I2C_Repeated_Start(); // Issue I2C signal repeated start
I2C_Wr(0xA3); // Send byte (device address + R)
PORTB = I2C_Rd(0u); // Read the data (NO acknowledge)
I2C_Stop();
}