Skip to main content
Choudharyas
Associate III
September 6, 2022
Question

Multiple CAN frames

  • September 6, 2022
  • 1 reply
  • 940 views

Hi,

I am working on a CAN Bus project with TCAN1051 and STM32G0. In this project i have to send approx. 175 bytes of data though CAN. It will take around 22 frames to send this data. And i can't figure out how to send all the frames. If i send all of them at once i might get RX_FIFO overflow error. Can anyone help me with this. Thanks

    This topic has been closed for replies.

    1 reply

    Javier1
    Principal
    September 6, 2022
     
    	//check space in the mailbox
    	howmanyTXmailboxes = HAL_CAN_GetTxMailboxesFreeLevel(hcan_object_reference);
     
    	if (howmanyTXmailboxes > 0) {
    		status = HAL_CAN_AddTxMessage(hcan_object_reference, &canTxheader,
    				messageTxData, &pTxMailbox);
    		if (status != HAL_OK) {
    			//Canbus_Error_handler(1); //error de transmision
    		}
    	}else{//OR FULL MAILBOX
    		status=HAL_BUSY;
    		HAL_CAN_AbortTxRequest(hcan_object_reference, CAN_TX_MAILBOX0+CAN_TX_MAILBOX1+CAN_TX_MAILBOX2);//empty all mailboxes
    	}

    Or, If you dont want to get very smart about it, a simple HAL_Delay(10) in between canbus TX should be enough (at 125Kbauds)

    hit me up in https://www.linkedin.com/in/javiermuñoz/
    Choudharyas
    Associate III
    September 6, 2022

    Okay got it, Thanks.