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;
}
////////////////////////////////////////
Hi Daniel.
Thanks for your time.
I finally solved it installing an isr handler with this code:
void I2C_IRQHandler(void)
{
OSA_SemaPost(&i2cmaster.irqSync);
I2C_HAL_ClearInt(i2cbase);
}
That's great, thanks for sharing
I am trying to debug the exception. CFSR and HFSR registers contain:
CFSR = 0x00040000 (INVPC = 1)
HFSR = 0x40000000 (FORCED = 1)
I implemented my own handler for the exception and used it to dump stack contents and see what is going on. The offending instruction, located at 0x572:
bx lr
lr register contains value 0x92fb.Instruction at 0x92fa is:
adds r7, #8
So I do not know what else I can do and why the exception is happening
Hi Jose:
I copied your code into my project, and tested in TWR-K64 , not found this issue, could you create a simple project for us to reproduce your issue?
Regards
Daniel
I checked with the scope that the address byte is being sent, but after that, unhandled interrupt happens and task is blocked.
Any idea?
Thanks