MKE02Z I2C0 issue

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

MKE02Z I2C0 issue

跳至解决方案
1,237 次查看
neilporven
Senior Contributor I

I am having an issue with the I2C module.  I am writing to an LCD controller chip that uses I2C.

If I step through my code, I can see all bytes being pumped out and the LCD controller chip is 

ACKing my bytes properly.  

The minute I let the software run, bytes don't appear on my scope,nor do I see the numbers I 

am pumping out to the LCD?????

I feel there is an issue with my I2C STATUS wait.  Here is the code for  the STATUS wait:

I2C0_D = ucData; //Write

//Make sure we Arbitration is not lost 1=Lost 0=Standard bus operation
if ((I2C0_S & I2C_S_ARBL_MASK) == 0)
  {//Begin if (Standard Bus Operation)

     //Wait until an acknowledge signal is detected
     while ((I2C0_S & I2C_S_RXAK_MASK) == 1)
        {
          return (1);
          break;
       }
  }//End if (Standard Bus Operation)
else
  I2C0_S |= I2C_S_ARBL_MASK; //Clear the arbitration

Thank you,

Neil

标签 (1)
0 项奖励
回复
1 解答
1,115 次查看
mjbcswitzerland
Specialist V

Hi

I would use the TCF or IICIF flag to wait for transmission and then the RXAK only to check whether a slave responded or not.

Possibly the RXAK flag is meaningless during transmission and so only set in an error case, which would cause your loop to immediately quit when run at normal speed (and something later abort transmission).

IICIF operation with interrupts would be generally more efficient, whereby KE02 code is identical to code for all KL and K parts (except newer double-buffered I2C controller types).

Regards

Mark

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,116 次查看
mjbcswitzerland
Specialist V

Hi

I would use the TCF or IICIF flag to wait for transmission and then the RXAK only to check whether a slave responded or not.

Possibly the RXAK flag is meaningless during transmission and so only set in an error case, which would cause your loop to immediately quit when run at normal speed (and something later abort transmission).

IICIF operation with interrupts would be generally more efficient, whereby KE02 code is identical to code for all KL and K parts (except newer double-buffered I2C controller types).

Regards

Mark

0 项奖励
回复
1,115 次查看
neilporven
Senior Contributor I

Hi Mark,

As always thank you!  I used the TCF and now it's working, I left the RXAK flag to make

sure the other chip is communicating.

Neil

0 项奖励
回复