Help with MC9S12XEG128 IIC

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Help with MC9S12XEG128 IIC

1,779件の閲覧回数
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,674件の閲覧回数
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,674件の閲覧回数
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 件の賞賛
返信