Showing results for 
Search instead for 
Did you mean: 

Some of CAN packet have trouble.

Associate III


I am developing CAN communication protocols using STM32F429.
However there is a problem in sending CAN frame data.


Here is a picture which I captured in CAN TX using logic analyzer, and as you can see, the series of data is losted after first data.


I tested this with publishing 100Hz, this problem occurred once a minute.

In normal case, it should be like this.



And also I add my code for helping to understanding.



	motorCANTxMailBox = HAL_CAN_GetTxMailboxesFreeLevel(&hcan1);
    HAL_CAN_AddTxMessage(&MTRL_CAN, &motorCANTxHeader, &motorCANTxData[0], &motorCANTxMailBox);



I disabled the non-automatic retransimission and enabled automatic bus-off feature.

But I wonder why the retransimission did not occur.





I can't show all my code because of the confidential. Instead, I show the CAN part of my codes.


here is the G0 code which is responsible for receiving the CAN frame.  

void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs){

		HAL_StatusTypeDef ref;

		ref = HAL_FDCAN_GetRxMessage(hfdcan, FDCAN_RX_FIFO0, &RxHeader, RxData);
		if (ref == HAL_OK){

			RxSLCANFrame.can_id = RxHeader.Identifier;
			tester = RxSLCANFrame.can_id;
			if ((RxSLCANFrame.can_id & uint32_t(0x0f)) == NODE_ID){

				RxSLCANFrame.can_id = (RxSLCANFrame.can_id & 0xfffffff0);

				memcpy(, RxData, CAN_Frame_len);

				CB_push(&cb_can_frame, &RxSLCANFrame);
				RxCANFrameFlag = true;
		} else {

		ref = HAL_FDCAN_ActivateNotification(hfdcan, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0);

		if (ref == HAL_OK){
		} else {


and here is F4 code which is in charge of transmitting the packets. and changed some name of the variables.

void CANCmd(const uint32_t node_id, const float rad1, const float rad2){
    uint32_t diriect_ID = 0x700 + node_id;
    uint8_t data[8] ={0,};
    data_frame64_t position_cmd_data;

    position_cmd_data.data_float_t[0] = rad1;
    position_cmd_data.data_float_t[1] = rad2;

    CANPacketCreate(diriect_ID, position_cmd_data.data8_t);

void CANPacketCreate(uint32_t id, uint8_t *data){
    CANTxHeader.StdId = id;
    CANTxHeader.IDE = CAN_ID_STD;
    CANTxHeader.DLC = 8;

    memset(CANTxData, 0, 8);
    memcpy(CANTxData, data, 8);

    CANTxMailBox = HAL_CAN_GetTxMailboxesFreeLevel(&MTRL_CAN);

void motorCANWrite(){
    CANTxMailBox = HAL_CAN_GetTxMailboxesFreeLevel(&MTRL_CAN);
    HAL_CAN_AddTxMessage(&MTRL_CAN, &CANTxHeader, &CANTxData[0], &CANTxMailBox);



Sorry I need at least ioc files otherwise I can't help you efficiently.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

OK. I'll upload it later. 

I found a trouble in my system.

I had added one more CAN Slave which received the data frames from the STMF4 board, and this was the reason why the CAN BUS didn't work.

After I eliminated this board, the system worked well.


Thank you so much for looking into my problem.




Not sure I understood how you did solve the problem.

You have one F429 board and in the other side there is a CAN analyzer (only two nodes on the bus). So you removed the third board F4! which board? but at first time this board was not connected to the bus!

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

The system actually is rather complicated because this board is one of machine systems. So I couldn't exactly catch the whole system structure.


In fact, STMF4 Board have two another CAN devices. One is STMG4 board which I mentioned, and other is another CAN Device, Battery BMS which I didn't catch. After checked this, I removed the BMS device from CAN BUS and then the problem was recovered.


I'm sorry to gave you some confusing parts.