FRDM-K64F I2C API MasterTxComplete Callback Status 0x451

cancel
Showing results for 
Search instead for 
Did you mean: 

FRDM-K64F I2C API MasterTxComplete Callback Status 0x451

Jump to solution
442 Views
pcpro178
Contributor III

I've implemented the I2C example from i2c_interrupt_b2b_transfer_master.c in my application.  I've verified that the interrupt is firing and the callback is getting called.  However, a status of 0x451 is being passed to the callback.  What does that status code mean?  The way the example is written, it looks like a status code of zero should be expected.

Here's my transmit code as implemented from the example.  Any help would be great.  Thanks.

[REDACTED]
Tags (1)
0 Kudos
1 Solution
212 Views
pcpro178
Contributor III

Okay, I got it to acknowledge messages by shifting my address byte right 1 bit for 7-bit addressing, so my address and register bytes are looking good.  However, the payload is still clearly incorrect.  The payload should be only 2 bytes: `{ 0x80, 0x70 }`.

pastedImage_1.png

UPDATE

The issue has been resolved.  The payload contents were being overwritten, before the I2C module could transmit, due to a race condition..

View solution in original post

0 Kudos
3 Replies
212 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Jim,

Regarding your question, this is the status defination for the function.

static void MasterTxRxCallback(I2C_Type *base, i2c_master_handle_t *handle, status_t status, void *userData)

//defined in fsl_common.h

#define MAKE_STATUS(group, code) ((((group)*100) + (code))) 

//defined in fsl_i2c.h

//kStatusGroup_I2C is 11

enum _i2c_status //
{
    kStatus_I2C_Busy = MAKE_STATUS(kStatusGroup_I2C, 0),            /*!< I2C is busy with current transfer. */
    kStatus_I2C_Idle = MAKE_STATUS(kStatusGroup_I2C, 1),            /*!< Bus is Idle. */
    kStatus_I2C_Nak = MAKE_STATUS(kStatusGroup_I2C, 2),             /*!< NAK received during transfer. */
    kStatus_I2C_ArbitrationLost = MAKE_STATUS(kStatusGroup_I2C, 3), /*!< Arbitration lost during transfer. */
    kStatus_I2C_Timeout = MAKE_STATUS(kStatusGroup_I2C, 4),         /*!< Wait event timeout. */
    kStatus_I2C_Addr_Nak = MAKE_STATUS(kStatusGroup_I2C, 5),        /*!< NAK received during the address probe. */
};

Obviously, if the status value is 0x451, 1105 in decimal, it is kStatus_I2C_Addr_Nak 

Hope it can help you

BR

Xiangjun Rong

0 Kudos
213 Views
pcpro178
Contributor III

Okay, I got it to acknowledge messages by shifting my address byte right 1 bit for 7-bit addressing, so my address and register bytes are looking good.  However, the payload is still clearly incorrect.  The payload should be only 2 bytes: `{ 0x80, 0x70 }`.

pastedImage_1.png

UPDATE

The issue has been resolved.  The payload contents were being overwritten, before the I2C module could transmit, due to a race condition..

View solution in original post

0 Kudos
212 Views
pcpro178
Contributor III

Thanks.  That confirms what I'm seeing with my logic analyzer.

pastedImage_1.png

What confuses me is why am I only seeing one byte transmitted, and not the three bytes that I expected?  This is how I have the message to be sent defined:

  buf[3] = { 0x02, 0x80, 0x70 };

My transfer is setup as so...I've added comments to show the values I see when I single-step with the debugger:

  memset(&Info[i2c].handle, 0, sizeof(i2c_master_handle_t));
  memset(&Info[i2c].xfer, 0, sizeof(i2c_master_transfer_t));

  Info[i2c].xfer.slaveAddress = addr;        // 0x40
  Info[i2c].xfer.direction = kI2C_Write;     // 0x00
  Info[i2c].xfer.subaddress = (uint32_t)reg; // 0x04
  Info[i2c].xfer.subaddressSize = 1;
  Info[i2c].xfer.data = buf;                 // address of { 0x02, 0x80, 0x70 }
  Info[i2c].xfer.dataSize = len;             // 0x03
  Info[i2c].xfer.flags = kI2C_TransferDefaultFlag;

  I2C_MasterTransferCreateHandle(Config[i2c].base, &Info[i2c].handle, MasterTxRxCallback, I2CU_Write);
  stat = I2C_MasterTransferNonBlocking(Config[i2c].base, &Info[i2c].handle, &Info[i2c].xfer);
  Info[i2c].inProgress = true;

My understanding of the `subaddress` is that it's supposed to be the register/command to the slave device.  If that's so, then I would expect the packet on the I2C bus to be something like `{ 0x40, 0x04, 0x80, 0x70 }`.  Is that not so?  Is there perhaps something with my transfer setup that I'm missing?

0 Kudos