10-bit extended I2C addressing

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

10-bit extended I2C addressing

2,281 Views
johannagunter
Contributor I

 I configure the MKL03Z32CAF4R for 10-bit extended I2C addressing.  When I receive the first byte of address, the IAAS bit is not set.  Is this what I should expect?  I have set the ADEXT bit for I2C and set the upper address bits and lower address bits to match the device.  Is there a different for chart for the 10-bit operation that I can reference?

0 Kudos
4 Replies

1,505 Views
johannagunter
Contributor I

I have implemented the addressing per the table, but the slave never sees IAAS = 1 (neither on the first address byte, nor the second).  I get the ACKs, but the interrupt handler never branches down IAAS = 1 (Y).

0 Kudos

1,505 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Johanna Gunter,

   Please post your I2C bus wave, and your code for 10bit I2C address.

  Then I will help you to do the deep research.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,505 Views
johannagunter
Contributor I

Kerry -

Here is the code for the slave initialization and interrupt handler.

This interrupt handler follows the slave path in the flowchart provided in the operators manual.

Slave initialization:

 

void initializeHWI2C(void)

{

if(boardID == 0){

I2C0_F_bit.MULT = 0x01;

I2C0_F_bit.ICR = 0x18;

}

PORTB_PCR3_bit.MUX = 2;

PORTB_PCR4_bit.MUX = 2;

I2C0_A1_bit.AD = boardID;

I2C0_C1_bit.IICEN = 1;

I2C0_C1_bit.IICIE = 1;

I2C0_C1_bit.WUEN = 1; //12-5 JLG to wakeup without peripheral clocks running

I2C0_FLT_bit.SSIE = 1;

NVIC_EnableIRQ(I2C_IRQ);

I2C0_C1_bit.TX = 1;

I2C0_C2_bit.ADEXT = 1;

I2C0_C2_bit.AD = 0; //extended 10-bit addr 10:8

}

 

Slave IRQ handler:

 

void I2C0_IRQHandler(void)

{

unsigned char dummy;

if(I2C0_FLT_bit.STOPF){

I2C0_FLT_bit.STOPF = 1;

I2C0_S_bit.IICIF = 1;

if(i2cRxCounter > 1){

dataReady = 1;

}

i2cRxCounter = 0;

i2cTxCounter = 0;

startCount = 0;

return;

}

if(I2C0_FLT_bit.STARTF){

I2C0_FLT_bit.STARTF = 1;

I2C0_S_bit.IICIF = 1;

startCount++;

if(startCount <= 1)

return;

}

else{

I2C0_S_bit.IICIF = 1;

}

if((i2cReadFlag > 1) && (i2cTxCounter==3) && (I2C0_C1_bit.TX == 1)){

I2C0_C1_bit.TXAK = 0;

I2C0_C1_bit.TX = 0;

dummy = I2C0_D_bit.DATA;

return;

}

// Master Mode

if(I2C0_C1_bit.MST){

// Tx

if(I2C0_C1_bit.TX){

// Last byte transmitted?

if(i2cTxCounter >= i2cTxTotalBytes){

I2C0_C1_bit.MST = 0;

}

else{

// RXAK = 0?

if(I2C0_S_bit.RXAK == 0){

if((i2cTxCounter == 2) && (i2cReadFlag==1)){

I2C0_C1_bit.RSTA = 1;

i2cReadFlag++;

}

else{

I2C0_D_bit.DATA = I2C_Tx_Buffer[i2cTxCounter++];

}

}

else{

I2C0_C1_bit.MST = 0;

}

}

}

// Rx

else{

if(i2cRxCounter >= i2cRxTotalBytes){

I2C0_C1_bit.MST = 0;

rxComplete = 1;

}

else if((i2cRxCounter+1) == i2cRxTotalBytes){

I2C0_C1_bit.TXAK = 1;

}

else{ }

I2C_Rx_Buffer[i2cRxCounter++] = I2C0_D_bit.DATA;

}

}

// Slave Mode

else{

if(I2C0_S_bit.IAAS){

if(I2C0_S_bit.SRW == 1){

I2C0_C1_bit.TX = 1;

updateI2Ccommand();

I2C0_D_bit.DATA = I2C_Tx_Buffer[i2cTxCounter++];

}

else{

I2C0_C1_bit.TX = 0;

dummy = I2C0_D_bit.DATA;

}

}

else{

if(I2C0_S_bit.SRW){

if(I2C0_S_bit.RXAK==0){

I2C0_D_bit.DATA = I2C_Tx_Buffer[i2cTxCounter++];

}

else{

I2C0_C1_bit.TX = 0;

dummy = I2C0_D_bit.DATA;

}

}

else{

I2C_Rx_Buffer[i2cRxCounter++] = I2C0_D_bit.DATA;

}

}

}

}

 

The following waveforms are a slave write (left) and slave read (right).  The slave address is 0b0000000001.

i2c_10-bit_write.jpgi2c_10-bit_read.jpg

From reference manual:

slave_flowchart.jpg

0 Kudos

1,505 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Johanna Gunter,

    Please check the KL03 reference manual, chapter 35.5.2 10-bit address at first, did you meet the 10bit address table? please also check your I2C bus data.

pastedImage_1.png


Please make sure you meet this table.

If you still have question, please let me know


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos