AnsweredAssumed Answered

I2C hanging after sending address byte

Question asked by JOSE ASENSIO on Jun 8, 2016
Latest reply on Jun 17, 2016 by Daniel Chen

Hello everyone.

I am using MQX 4.2 and KSDK 1.3. Using the following code I am getting a hard fault exception but I am not sure where it comes from:

 

/////////////////////////////////////////

void I2C0_IRQHandler(void)

{

int i;

I2C_DRV_IRQHandler(I2C0_IDX);

}

 

 

void InitI2C(void)

{

MUTEX_ATTR_STRUCT mutexattr;

uint8_t txBuff[10], cmd[4];

uint8_t count = 3;


I2C_DRV_MasterInit(BOARD_I2C_INSTANCE, &i2cmaster);

I2C_DRV_MasterSendData(BOARD_I2C_INSTANCE, &device, cmd, 0, txBuff, 1);

}j

/////////////////////////////////////////

 

It seems to be happening at this point:

 

////////////////////////////////////////

 

static i2c_status_t I2C_DRV_MasterWait(uint32_t instance, uint32_t timeout_ms)

{

 

i2c_master_state_t * master = (i2c_master_state_t *)g_i2cStatePtr[instance];

 

osa_status_t syncStatus;

 

 

do {

    syncStatus = OSA_SemaWait(&master->irqSync, timeout_ms);   // After this point I2C hangs

 

} while(syncStatus == kStatus_OSA_Idle);

 

if (syncStatus != kStatus_OSA_Success)

 

    master->status = kStatus_I2C_Timeout;

 

return master->status;

}

 

////////////////////////////////////////

Outcomes