Hello, thank you for always answering my questions.
Today, I would like to ask about the data receiving problem of CAN IF3 Interrupt.
The test I do is a test in which the HMI sends 3 frames of data to the CPU, and the CPU analyzes the data upon receiving the data and sends a response signal if the data is correct.
At this time, CPU receives data using CAN IF3.
However, sometimes the CPU could not receive the last frame data. Therefore, please check if the CAN IF3 Interrupt I made is wrong.
And I would like to ask if I need to check Interrupt pending register in CAN IF3 Interrupt.
Below is the CAN IF3 Interrupt code I made.
#pragma CODE_STATE(can1IF3UpdateInterrupt, 32) #pragma INTERRUPT(can1IF3UpdateInterrupt, IRQ) void can1IF3UpdateInterrupt(void) { uint32_t value = (canREG1->IF3OBS & 0x9800) >> 8; // IF3 Update data, IF3 Data A, IF3 Data B bit 확인 = 데이터 수신 확인 uint32_t ID = canREG1->IF3ARB; // IF3 수신 데이터 ID uint32_t ES_value; // error status register if(value == 0x98U) // IF3 데이터 수신 확인 { canIF3Notification(canREG1, ID); // canIF3Notification에서 CAN과 ID로 구분하여 수신 동작 처리 } else // CAN1 IF3 interrupt error { Send_SCI("Check IF3 1\r\n"); ES_value = canREG1->ES; if((ES_value & 0x1E0U) != 0U) { canErrorNotification(canREG1, ES_value & 0x1E0U); } else { canStatusChangeNotification(canREG1, ES_value & 0x618U); } } }
#pragma WEAK(canIF3Notification) void canIF3Notification(canBASE_t *node, uint32 ID) { uint32_t uiId = 0; uiId = ID & 0x1FFFFFFF; if((node == canREG1) && (uiId == CAN_HMI_ID_IN_CPU)) // CAN1 IF3의 ID 4 데이터 수신 from HMI { uint8_t i = 0; for(i = 0; i<8; i++) // 1Frame = 8Byte이므로 1Byte씩 8번 반복 { ucCan1RxBuffer[uiCan1RxIndex] = node->IF3DATx[i]; // IF3 Data A, B 데이터를 RX1 버퍼로 복사 Log_Msg_Save_RX(ucCan1RxBuffer[uiCan1RxIndex]); Frame_Data_Save(ucCan1RxBuffer[uiCan1RxIndex]); uiCan1RxIndex = (uiCan1RxIndex + 1) & CAN_RX_BUFFER_MASK; } #if 1 uint8_t ucMsb1ms; uint8_t ucLsb1ms; ucMsb1ms = (uint8_t)((us1sCounter & 0xFF00)>>8); ucLsb1ms = (uint8_t)(us1sCounter & 0x00FF); Log_Msg_Save_RX(ucMsb1ms); Log_Msg_Save_RX(ucLsb1ms); ucMsb1ms = (uint8_t)((us1msCounter & 0xFF00)>>8); ucLsb1ms = (uint8_t)(us1msCounter & 0x00FF); Log_Msg_Save_RX(ucMsb1ms); Log_Msg_Save_RX(ucLsb1ms); #endif } else { //asm(" nop "); Send_SCI("Check IF3 2\r\n"); } }