Help with MC9S12XEG128 IIC

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Help with MC9S12XEG128 IIC

1,793 次查看
hansonhe
NXP Employee
NXP Employee

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;
}
}

0 项奖励
回复
2 回复数

1,688 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi hansonhe,

S12XEG and S12ZVC have the same IICV3 module, so you can refer to the example posted here:

Internal I2C single Byte Read 

BR, Daniel

0 项奖励
回复

1,688 次查看
kef2
Senior Contributor V

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 

0 项奖励
回复