Showing results for 
Search instead for 
Did you mean: 

STM32H7 TTCAN Time Reference Messages with External Loopback Mode?

STeve D
Associate II


Problem: I'm getting errors when trying to send ttcan time reference messages while FDCAN1 is set to external loopback mode.


I have an application where we are using TTCAN effectively with one device acting as a TTCAN-Master and sending time reference messages to nodes on the same can bus. The fdcan protocol we're using is 1Mbps/4Mbps with bit rate switching.  We have a new application where it would be helpful if we could use the master with FDCAN1 set in external loopback mode while sending the time reference messages. However, when I switch the fdcan mode from FDCAN_MODE_NORMAL to FDCAN_MODE_EXTERNAL_LOOPBACK I start seeing errors in the time reference messages. They are still appearing at the correct rate and with no CAN frame errors, but the discontinuity bit is set and the cycle_count is not counting, just stuck at 1. So I'm wondering if it is possible to send the time reference messages when set to external loopback?  And if so, what change might fix this?

More info:

The .Mode field below marks the only change between the working vs non-working states:


FDCAN_InitTypeDef m_fdcan1_config = {
    .FrameFormat = FDCAN_FRAME_CLASSIC,
    .AutoRetransmission = ENABLE,
    .TransmitPause = DISABLE,
    .ProtocolException = DISABLE,
    .NominalPrescaler = FDCAN_NOMINAL_PRESCALER_500_kHz,
    .NominalSyncJumpWidth = 1,
    .NominalTimeSeg1 = FDCAN_NOMINAL_TIME_SEG_1_500_kHz,
    .NominalTimeSeg2 = FDCAN_NOMINAL_TIME_SEG_2_500_kHz,
    .DataPrescaler = FDCAN_NOMINAL_PRESCALER_4_MHz,
    .DataSyncJumpWidth = 1,
    .DataTimeSeg1 = FDCAN_NOMINAL_TIME_SEG_1_4_MHz,
    .DataTimeSeg2 = FDCAN_NOMINAL_TIME_SEG_2_4_MHz,
    .MessageRAMOffset = 0,


Here are the ttcan registers as captured after the first completed time reference message. With working unit (left) and non-working (right). The only notable differences I see are that the working unit shows GTD (global time discontinuity) bit of TTIR is set. Which is counterintuitive to me because the discontinuity bit in the time reference messages is 0 for this working unit.  And secondly TTCM shows capture cycle time is 1740 instead of 1739.

The first thought I had was that the error was due to problems with the delay compensation, since Rx was now being connected internally to Tx. So I tried reducing the delay compensation values and disabling it completely. This did have the effect of TTCSM now equaling 0x6cb like the working unit.  But no change in the error behavior. 



HAL_FDCAN_ConfigTxDelayCompensation(&handle->hal, delay_offset, delay_filter);


In case it's helpful the default FDCAN_TT_ConfigTypeDef fields look like this:


static FDCAN_TT_ConfigTypeDef m_ttcan_master_config = {
    .SyncDevLimit = 7,
    .InitRefTrigOffset = 0,
    .AppWdgLimit = 0,  // Disabled
    .ClockCalibration = FDCAN_TT_AUTO_CLK_CALIB_ENABLE,
    .BasicCyclesNbr = TTCAN_CONFIG_CYCLES_PER_MATRIX, // 32
    .CycleStartSync = FDCAN_TT_NO_SYNC_PULSE,
    .TxEnableWindow = 3,
    .ExpTxTrigNbr = 0,
    .TURNumerator = TURn_NTU_1US, // Set for 80 MHz FDCAN clock
    .TURDenominator = TURd_NTU_1US, // Set for 80 MHz FDCAN clock
    .TriggerMemoryNbr = ARRAY_SIZE(g_ttcan_cycle_schedule) + 1,



Thanks for your help, and please let me know if you need more info.


STeve D
Associate II

Any ideas would be greatly appreciated.

TriggerMemoryNbr = ARRAY_SIZE(g_ttcan_cycle_schedule) + 1

Why this?