AnsweredAssumed Answered

LPC4357 CAN cannot receive

Question asked by hua ST on Jul 25, 2018
Latest reply on Jul 25, 2018 by jeremyzhou

Hello everyone, I use LPC4357, CAN function, I send a data to the board through the PC, after the board receives, reply, the PC sends (Chip_CCAN_Send(LPC_C_CAN0, CCAN_MSG_IF1, false, &msg_buf);)the same data again, at this time CAN can only enter the RXOK state of the interrupt, cannot enter the msg interrupt again .Or  the board sends the data once, the board can only enter the receiving RXOK state interrupt, but can not enter the msg interrupt.,Have some people encountered this similar problem?

 

 

void CAN0_IRQHandler(void)
{
CCAN_MSG_OBJ_T msg_buf;
uint32_t can_int, can_stat, i;
while ( (can_int = Chip_CCAN_GetIntID(LPC_C_CAN0)) != 0 ) {
if (can_int & CCAN_INT_STATUS) {
can_stat = Chip_CCAN_GetStatus(LPC_C_CAN0);
// TODO with error or TXOK, RXOK
if (can_stat & CCAN_STAT_EPASS) {
DEBUGOUT("Passive error\r\n");
return;
}
if (can_stat & CCAN_STAT_EWARN) {
DEBUGOUT("Warning!!!\r\n");
return;
}
if (can_stat & CCAN_STAT_BOFF) {
DEBUGOUT("CAN bus is off\r\n");
return;
}
Chip_CCAN_ClearStatus(LPC_C_CAN0, CCAN_STAT_TXOK);
Chip_CCAN_ClearStatus(LPC_C_CAN0, CCAN_STAT_RXOK);
}
else if ((1 <= CCAN_INT_MSG_NUM(can_int)) && (CCAN_INT_MSG_NUM(can_int) <= 0x20)) {
// Process msg num canint
Chip_CCAN_GetMsgObject(LPC_C_CAN0, CCAN_MSG_IF1, can_int, &msg_buf);
switch (msg_buf.id) {
case CCAN_RX_MSG_ID:
DEBUGOUT("Msg ID :%x\r\n", msg_buf.id);
DEBUGOUT("Msg data :");
for (i = 0; i < msg_buf.dlc; i++) {
DEBUGOUT("%x ", msg_buf.data[i]);
}
DEBUGOUT("\r\nFeed back...\r\n");
msg_buf.id += 1;
Chip_CCAN_Send(LPC_C_CAN0, CCAN_MSG_IF1, false, &msg_buf);
break;

case CCAN_TX_MSG_ID:
break;

case CCAN_TX_MSG_REMOTE_ID:
msg_received_counter++;
if (msg_received_counter == 5) {
DEBUGOUT("Remote transmit total is 5. Delete remote ID\r\n");
Chip_CCAN_DeleteReceiveID(LPC_C_CAN0, CCAN_MSG_IF1, CCAN_TX_MSG_REMOTE_ID);
}
break;

default:
break;
}
}
}
}

Outcomes