Bom dia, colegas.
Desenvolvi um codigo para comunicação do pic com uma memória I2C (24C02) no mikroC. Creio que esta gravando correto na memória, só que quando vai ler a memória da vez de ler as letras (A – B - C – D – E – F – G – H – I – J – K – L – M – N – O – P). Lê duas vezes a seguinte seqüência: (I – J – K – L – M – N – O – P).
Será que algum dos colegas poderia me ajudar neste codigo
void main(){
PORTB = 0;
TRISB = 0;
PORTB = 255;
delay_ms(1000);
PORTB = 0;
USART_Init(19200);
I2C_Init(100000);
delay_ms(1000);
I2C_Start(); // issue I2C start signal
I2C_Wr(0xA0); // send byte via I2C (command to 24cO2)
I2C_Wr(0);
I2C_Wr(65); // send byte (address of EEPROM location)
I2C_Wr(66); // send byte (address of EEPROM location)
I2C_Wr(67); // send byte (address of EEPROM location)
I2C_Wr(68); // send byte (address of EEPROM location)
I2C_Wr(69); // send byte (address of EEPROM location)
I2C_Wr(70); // send byte (address of EEPROM location)
I2C_Wr(71); // send byte (address of EEPROM location)
I2C_Wr(72); // send byte (address of EEPROM location)
I2C_Wr(73); // send byte (address of EEPROM location)
I2C_Wr(74); // send byte (address of EEPROM location)
I2C_Wr(75); // send byte (address of EEPROM location)
I2C_Wr(76); // send byte (address of EEPROM location)
I2C_Wr(77); // send byte (address of EEPROM location)
I2C_Wr(78); // send byte (address of EEPROM location)
I2C_Wr(79); // send byte (address of EEPROM location)
I2C_Wr(80); // send byte (address of EEPROM location)
I2C_Stop();
Delay_ms(2000);
I2C_Start(); // issue I2C start signal
I2C_Wr(0xA0); // send byte via I2C (device address + W)
I2C_Wr(0); // send byte (data address)
I2C_Repeated_Start(); // issue I2C signal repeated start
I2C_Wr(0xA1); // send byte (device address + R)
USART_Write(I2C_Rd(1));
USART_Write(I2C_Rd(2));
USART_Write(I2C_Rd(3));
USART_Write(I2C_Rd(4));
USART_Write(I2C_Rd(5));
USART_Write(I2C_Rd(6));
USART_Write(I2C_Rd(7));
USART_Write(I2C_Rd(8));
USART_Write(I2C_Rd(9));
USART_Write(I2C_Rd(10));
USART_Write(I2C_Rd(11));
USART_Write(I2C_Rd(12));
USART_Write(I2C_Rd(13));
USART_Write(I2C_Rd(14));
USART_Write(I2C_Rd(15));
USART_Write(I2C_Rd(16));
I2C_Rd(0);
I2C_Stop();
}
Sds
Vanderley