We are using a MC9S12XEG128 microprocessor. We work as master i2c, need to communicate with slave PCF85162 chip using IIC.
The program sometimes run at below ack code when board power on. We want to know how to restore I2C bus, such as reset I2C module or exit this while.
while(IIC0_IBSR_RXAK);
Do you have some method for this? We try add below Illegal address jump when overflow is more than 65530, but it didn't work.
asm JMP 0xD000;
We attached some code as below for review, thanks.
IIC0_IBCR_MS_SL = 1; // Set transmit and master mode
IIC0_IBCR_TX_RX = 1; // And generate start condition
IIC0_IBDR = 0x70; // Adress the slave and set up for master transmit
while (!IIC0_IBSR_IBIF); // wait until IBIF (no time overflow considered!)
IIC0_IBSR_IBIF=1; // clear the interrupt event flag
while(IIC0_IBSR_RXAK) {
++overflow;
if(overflow>65530) {
overflow=0 return;
}
}
Hi hansonhe,
S12XEG and S12ZVC have the same IICV3 module, so you can refer to the example posted here:
BR, Daniel
Hi,
It is wrong to wait for RXAK. You always should wait for IBIF, transfer complete. Once RX ir TX transfer is complete and if it was TX, RXAK reflects the status of ACK from receiver. Receiver, depending on its protocol may never ACK at all.
Edward