2024-04-16 07:26 AM
Hi,
Problem: I'm getting errors when trying to send ttcan time reference messages while FDCAN1 is set to external loopback mode.
Description:
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:
FDCAN_InitTypeDef m_fdcan1_config = {
.FrameFormat = FDCAN_FRAME_CLASSIC,
.Mode = FDCAN_MODE_EXTERNAL_LOOPBACK, //FDCAN_MODE_NORMAL,
.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,
};
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_EnableTxDelayCompensation(&handle->hal);
HAL_FDCAN_ConfigTxDelayCompensation(&handle->hal, delay_offset, delay_filter);
static FDCAN_TT_ConfigTypeDef m_ttcan_master_config = {
.OperationMode = FDCAN_TT_COMMUNICATION_LEVEL2,
.GapEnable = FDCAN_STRICTLY_TT_OPERATION,
.TimeMaster = FDCAN_TT_POTENTIAL_MASTER,
.SyncDevLimit = 7,
.InitRefTrigOffset = 0,
.ExternalClkSync = FDCAN_TT_EXT_CLK_SYNC_DISABLE,
.AppWdgLimit = 0, // Disabled
.GlobalTimeFilter = FDCAN_TT_GLOB_TIME_FILT_ENABLE,
.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.
2024-04-18 08:17 AM
Any ideas would be greatly appreciated.
2024-04-18 10:54 AM
TriggerMemoryNbr = ARRAY_SIZE(g_ttcan_cycle_schedule) + 1
Why this?