Skip to main content
Graduate II
December 15, 2024
Solved

STLINK-V3MODS - CAN write error BRG_TARGET_CMD_TIMEOUT

  • December 15, 2024
  • 3 replies
  • 1726 views

Using he STLINKV3MOD, I2C, UARTs,  GPIO and using ti for SWD are all working fine without without errors for over a month and quite intensive use

The CAN code follows the same settings in  the example code:

InitCAN is successful.

WriteMsgCAN(&canTxMsg, dataTx, size); fails  with error 0x14 
BRG_TARGET_CMD_TIMEOUT  = Timeout error during Bridge communication
 
Which conditions can cause this error ? 
 
References:
Ubuntu Linux
Bridge 0 PID: 0X3753 SN:00240041343151093739.....

Selected Bridge STLink serial nmber:0024004134315109......

Bridge voltage: 3.274617 V

Bridge Firmware: v3 B5

Test Clock Command...

SPI input CLK: 48000 KHz, ST-Link HCLK: 192000 KHz

I2C input CLK: 192000 KHz, ST-Link HCLK: 192000 KHz

CAN input CLK: 48000 KHz, ST-Link HCLK: 192000 KHz

GPIO input CLK: 192000 KHz, ST-Link HCLK: 192000 KHz

PIO Test OK
Test CAN...
CAN prescaler initialized
CAN initialized and message reception succeeded
CAN filter initialization succeeded
CAN loopback test loop 1 with size 1
CAN Write Message error (Tx ID: 0x12345678)
Timeout error during Bridge communication

 
 
    This topic has been closed for replies.
    Best answer by AM

    Hello,

    Yes a target must be present on the CAN bus to receive and acknowledge the sent CAN messages. If you have no CAN target connected to the STLINK and you just want to see how the STLINK CAN API is working, you may use CAN_MODE_LOOPBACK to receive back the sent messages on the CAN bus. In that case you need to configure the STLINK CAN reception (filter/ message reception) accordingly.

    Best regards

     

     

    3 replies

    ST Employee
    January 2, 2025

    Hello

    You may need to check the CAN bus connections and the CAN target you are connected to.  It seems you are failing at the first trial of CAN communication on the bus after CAN and filters initialization: the sent CAN message seems not received by your target (probably the command timeout in receiving the target ACK). On STLINK-V3MODS side, verify that the CAN baud rate configured in  Brg_CanInitT  from STLINK-V3-BRIDGE API (in function InitCAN() GetCANbaudratePrescal()) are matching the configuration used on your CAN target side. You may also verify on the target side if initialization and filters are correctly set to receive the message you are sending using the STLINK-V3MODS.

    For CAN debug you may also have a look to this article Troubleshooting bxCAN issues in Loop Back mode on STM32 MCUs

    Best regards

    debuggingAuthor
    Graduate II
    January 4, 2025

    Many thanks. Thus "Timeout error during Bridge communication" means a problem on the CAN bus. The description  looked more like an error communication error between the Host and the STV3MOD USB connection, so I stopped analyzing this from there.. A more verbose explanation for possible causes of these bridge errors would help.

    Bottom line, there  should be activity visible on the CAN bus & Rx/Tx pins, even with this error, correct ?

     

     

    ST Employee
    January 6, 2025

    Hello,

     BRG_TARGET_CMD_TIMEOUT  is the error when a timeout occurs while the STLINK is waiting for the answer of the target to a Bridge command (generic error for all Bridge interfaces). It is difficult to be more precise in describing the error because the root cause of this issue can be due to various factors (bridge hardware connection issues, target code, mismatch between STLINK and target configuration ...) .

    Yes you should be able to see the STLINK CAN Tx activity on  the CAN bus & Rx/Tx pins.

    Best regards

    debuggingAuthor
    Graduate II
    January 23, 2025

    Hello @AM 

    Checked the board again. Connected an 120 Ohm resistor between CAN-H and L. Nothing else is connected to the CAN BUS.  Checked with a multimeter this 120 Ohm all the other CAN bus connection to the transceiver and the V3MOD. VIO of the CAN transceiver measures 3.3V. VCC to the transceiver measures 5V. When the V3MOD is idle (no Bridge transactions), CAN_L and CAN_H are 3.3V and the TJA1051-T3 outputs are both 2.397V. When the code of the initialization starts CAN_L and CAN_H signals are changing as well those on the CAN Bus. it does not seems to be a hardware issue. Reading back the CAN bus status after initialization gives a final baud-rate of 125000 (same as requested). Must a target be present on the bus  ? Attached code snippet.

     

     

    debuggingAuthor
    Graduate II
    February 2, 2025

    @AM Many thanks, I just build a CANABLE alike board today using STM32F0 as a target and added the termination resistor on the STV3MOD.  It works fine now.  Thank for the package update. Will check it out.