I have a problem with the i2C when I initialize the C_Can on LPC11C24. If I don't initialize the C_Can in my code everything works well, but when I add it and i debug the system the I2C stops working. To integrate the C-Can into my code I used the nxp example. My I2C initialization is:
//I2C
Chip_SYSCTL_PeriphReset(RESET_I2C0);
Chip_I2C_Init(I2C0);
Chip_I2C_SetClockRate(I2C0, I2C_SPEED);
i2c_set_mode(I2C0, 0);
While the C_Can initialization is:
void Init_Can(void){// //CAN
/* Publish CAN Callback Functions */
CCAN_CALLBACKS_T callbacks = {
CAN_rx,
CAN_tx,
CAN_error,
NULL,
NULL,
NULL,
NULL,
NULL,
};
baudrateCalculate(TEST_CCAN_BAUD_RATE, CanApiClkInitTable);
LPC_CCAN_API->init_can(&CanApiClkInitTable[0], TRUE);
//Configure the CAN callback functions
LPC_CCAN_API->config_calb(&callbacks);
// Enable the CAN Interrupt
NVIC_SetPriority(CAN_IRQn, 7);
NVIC_EnableIRQ(CAN_IRQn);
}
The system remains into the following function:
void Chip_I2C_EventHandler(I2C_ID_T id, I2C_EVENT_T event)
{
struct i2c_interface *iic = &i2c[id];
volatile I2C_STATUS_T *stat;
/* Only WAIT event needs to be handled */
if (event != I2C_EVENT_WAIT) {
return;
}
stat = &iic->mXfer->status;
/* Wait for the status to change */
while (*stat == I2C_STATUS_BUSY) {} // the system remains here
}
any ideas? I need to use the I2C and the C_Can together but it seems that at the I2C doesn't like the C_Can.