Skip to main content
themole
Associate II
July 27, 2018
Question

Cannot Trasmit messages because CAN is always in state HAL_CAN_STATE_LISTENING?

  • July 27, 2018
  • 5 replies
  • 2581 views

Currently I'm trying to get CAN up and running on a STM32F469NIH6 based Board using the CubeMX libraries.

Unfortunately, the documentation of the new HAL_CAN driver is very limited. I found an example in STM32Cube_FW_L4_V1.12.0\Projects\STM32L476G-EVAL\Examples\CAN\CAN_Networking\Src\main.c, but even with identical code (except the clock settings), it is not working, because the frame I added with HAL_CAN_AddTxMessage(&hcan1, &txHeader, data, &txMailbox) is not being sent, possibly because of the HAL_CAN_STATE_LISTENING.

My RX and TX lines (to the CAN-Transceiver) are both in HIGH-State (3.3V) and they keep being there when trying to transmit. CAN_H and CAN_L itself is in High-Z state, both lines are around 2V, Vdiff = 0V

Is there anything I can do wrong? Any suggestions how to debug this down to the problem?

    This topic has been closed for replies.

    5 replies

    T J
    Senior III
    July 27, 2018

    Are you running a line driver with a terminator ?

    is there another device on the canBus ?

    themole
    themoleAuthor
    Associate II
    July 27, 2018

    Yes, both ends are terminated with 120 Ohms and I run with a ISO1050 Transceiver from Texas.

    Yes, there is another devices, that sends something when I switch the system on.

    I have some very old firmware running on that board (using the old ST Standard Libraries), that where able to send something.

    T J
    Senior III
    July 27, 2018

    I use this method to transmit.. checking all three mailboxes manually.

    if ((CAN->TSR & CAN_TSR_TME0) == CAN_TSR_TME0) // (1) 
    { 
     CAN->sTxMailBox[0].TDTR = canTxMsgLength[canTxMsgOUT]; // (2) length
     CAN->sTxMailBox[0].TDLR = canTxMsgBottomWord[canTxMsgOUT]; // (3) 4bytes
     CAN->sTxMailBox[0].TDHR = canTxMsgTopWord[canTxMsgOUT]; // (3) 4bytes
     CAN->sTxMailBox[0].TIR = ((uint32_t)canTxMsgID[canTxMsgOUT] << 21 | CAN_TI0R_TXRQ); // (4) // send it now if the line is idle
    }
     
    if ((CAN->TSR & CAN_TSR_TME1) == CAN_TSR_TME1) // (1) 
    if ((CAN->TSR & CAN_TSR_TME2) == CAN_TSR_TME2) // (1) 
     

    AlexF
    Associate
    September 20, 2018

    I have the same problem with my STM32F437ZI

    @themole cuold you solve it?

    Can somebody solve the topic with the HAL interface?

    Bertrand1
    Senior
    September 24, 2018

    I have some time the same probleme. It works for a long time after but some times, Tx buffers become full. After a reset, all is working fine without any change in term of hardware. So I should solve this issue with software.

    I check if tx mailbox are full with HAL_CAN_GetTxMailboxesFreeLevel(pcan);

    If not, I clear wiht this HAL_CAN_AbortTxRequest(pcan, 0); HAL_CAN_AbortTxRequest(pcan, 1); HAL_CAN_AbortTxRequest(pcan, 2); but it not solved or partialy ( the fault occurence is less)

    The fact that the state in HAL_CAN_SATE_LISTENING seems to not be the issue.

    Thanks for your advise.

    Bertrand