Tool/software: TI-RTOS
Hi,
I am calling a i2c_write function inside a ISR function, But its showing some error like below...
ssertion failure: A_badContext: bad calling context. Must be called from a Task.
xdc.runtime.Error.raise: terminating execution
/* ISR function call */
ISRHandlerFunction()
{
/*clearing flags and led toggling is done*/
(* (volatile uint32_t *)clearFlagaddr) = bit_shift;
GPIO_toggle(Board_LED0);
I2cWrite();
}
/* I2C write funcation */
I2cWrite()
{
uint8_t vui8Count;
System_printf("i2c write\n");
//System_flush();
/* Create I2C for usage */
I2C_Params_init(&stI2cParams);
stI2cParams.bitRate = I2C_400kHz;
stI2cHandle = I2C_open(stI2cConfig->vui8I2cBus, &stI2cParams);
if (stI2cHandle == NULL) {
System_abort("Error Initializing I2C\n");
}
else {
System_printf("I2C Initialized!\n");
}
for (vui8Count = 0; vui8Count < (stI2cConfig->vui8writeCount - 1); vui8Count++) {
if (I2C_transfer(stI2cHandle, &stI2cTransaction)) {
System_printf("Send data %d : %d \n", vui8Count+1, stI2cConfig->pui8txbuffer);
}
else {
System_printf("I2C Bus fault\n");
}
//System_flush();
}
/* Deinitialized I2C */
I2C_close(stI2cHandle);
}
the above is the actual code, its just a format of code.
if I comment down the i2cWrite function, ISR function working fine. If I use inside ISR, Its showing the above error.
Want to know why this error is coming.
Regards,
Manohar