cancel
Showing results for 
Search instead for 
Did you mean: 

A problem occurs when STM32 sends multiple CAN messages.

KondenserSoketi
Associate II

In my STM32 software code three canbus messages sent (extended). When i connect the PCAN Can-USB tranciever i see my messages on the PC clearly. But after a while the state of bus gets "BUSHEAVY" and sending messages stop.

Is the problem related with sending three CAN messages make all mailboxes full?

Here is my code block given below.

HAL_CAN_AddTxMessage(&hcan1, &pTxHeader, &count, &pTxMailbox);

HAL_CAN_AddTxMessage(&hcan1, &pTxHeader1, &count1, &pTxMailbox1);

HAL_CAN_AddTxMessage(&hcan1, &pTxHeader2, &count2, &pTxMailbox2);

After,

I updated my code as given below

while (HAL_CAN_GetTxMailboxesFreeLevel(&hcan1) >=1

{

HAL_CAN_AddTxMessage(&hcan1, &pTxHeader, &count, &pTxMailbox);

HAL_CAN_AddTxMessage(&hcan1, &pTxHeader1, &count1, &pTxMailbox1);

HAL_CAN_AddTxMessage(&hcan1, &pTxHeader2, &count2, &pTxMailbox2);

}

I am testing the code for 2 hours and all is good. What do ypu think about it. Is it real solution?

Another possbility to fail: I am using UART for communication with a touch screen at the same time and i see that every extra UART communication (sending data to screen) makes the CAN message period increased. Is it strange but fact. Is there any relationship using CAN and UART at the same code? Could you please help me aboput the issues?

Thanks in advance.

0 REPLIES 0