Question
STM32F427 CAN Error Status
Posted on September 15, 2016 at 17:40
STM32CubeMX 4.16 STM32Cube FW_F4 V1.13.0
I have CAN working OK and need to get the Error Status, I have the following Code fragment but do not receive an Error Code when a CAN Error occurs i.e. disconnected. hcan1.pTxMsg->StdId = Out_ID; hcan1.pTxMsg->DLC = 8; hcan1.pTxMsg->RTR = CAN_RTR_DATA; hcan1.pTxMsg->IDE = CAN_ID_STD; hcan1.pTxMsg->Data[0] = byte1; hcan1.pTxMsg->Data[1] = byte2; hcan1.pTxMsg->Data[2] = byte3; hcan1.pTxMsg->Data[3] = byte4; hcan1.pTxMsg->Data[4] = byte5; hcan1.pTxMsg->Data[5] = byte6; hcan1.pTxMsg->Data[6] = byte7; hcan1.pTxMsg->Data[7] = byte8; if(HAL_CAN_Transmit_IT(&hcan1) != HAL_OK) { CAN1_Error_Code = hcan1.ErrorCode; LED1(ON); // HAL_CAN_ERROR_NONE 0x00U /*!< No error */ // HAL_CAN_ERROR_EWG 0x01U /*!< EWG error */ // HAL_CAN_ERROR_EPV 0x02U /*!< EPV error */ // HAL_CAN_ERROR_BOF 0x04U /*!< BOF error */ // HAL_CAN_ERROR_STF 0x08U /*!< Stuff error */ // HAL_CAN_ERROR_FOR 0x10U /*!< Form error */ // HAL_CAN_ERROR_ACK 0x20U /*!< Acknowledgment error */ // HAL_CAN_ERROR_BR 0x40U /*!< Bit recessive */ // HAL_CAN_ERROR_BD 0x80U /*!< LEC dominant */ // HAL_CAN_ERROR_CRC 0x100U /*!< LEC transfer error */ // Display value ... CAN1_Error_Code; } Am I thinking about this too simply or should hcan1.ErrorCode; return a non zero value when an error occurs My LED comes on when CAN1 is disconnected but the ErrorCode is 0. Any advise would be of great help. KR John W #no-hablo-hal #no-hablo-hal