Before I received the reply for my message, I changed the SCLK frequency and works. The troubble is:
I need to read from the slave device, a serial E2PROM memory (24LC256); it's seems the microcontroller can't hold on the information from memory because the micro read the IBDR but inmediatly change to the next data and can't store on memory. I tried testing with many bit flags: TCF, IBB, and IBIF, without success, sometimes it can recognize those bits and go to the next instruction, sometimes doesn't. In additon, I work my I2C read routine in polling mode but Interruption mode. Something peculiar, sometimes the SRW bit is set and I don't have the micro as Slave, just Master. Why happens this?
here go a part of the code in C:
/******************************************************************/
/* c. Re-Enviar Señal de START */
IIC_Start(leer);
/* d. Tomar los datos que lee en BDR y pasarlos a Buffer de Rx Data_I2C */
for(i=0;i<=*Tam_buf_I2C;i++){
while(!b_TestBit(IBSR_IBIF,IBSR)); /* mientra bus está ocupado */
dummy_I2C = IBDR;
Data_I2C[i]= dummy_I2C; //dummy_I2C;
b_SetBit(IBSR_IBIF,IBSR);
}
b_ClearBit(3,IBCR); // envia un ACK y termina
IIC_Stop();
/* Deshabilitar Modulo I2C para evitar Flag de BusyBus inexistentes*/
IBCR &= 0x7F;
/******************************************************************/
IICStart(leer) is a function that re-send the START signal and then the Slave address with last bit Set (R=1).
After that I wait for incoming data, reading the IBDR; in debugging mode works, that is, with BreakPoints in Code Warrior's Realtime Debugger. With out break points the micro only watches 0xFF, 0x00 even 0x01. I thougth the problem is Clock Speed, so I changed to 75KHz without success.
1. Is needed the I2C module works only in Interrupt mode?
2. in polling mode, exists a flag bit that lets me work in this mode?
Thanks for your Help!
Giovanni Garcia