MKE02Z I2C0 issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MKE02Z I2C0 issue

Jump to solution
590 Views
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

Labels (1)
0 Kudos
1 Solution
468 Views
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

View solution in original post

0 Kudos
2 Replies
469 Views
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 Kudos
468 Views
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 Kudos