cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G484-EVAL FDCAN works without BRS, gives stuff errors with BRS turned on

HTamh.1
Associate II

FDCAN clock: 80Mhz

I'm using PCAN view to test this, with proper settings (8Mbps data rate,80Mhz clock,Nominal bit rate of 1Mbps). Works when I turn the BRS off in the TxHeader. Shows stuff error messages with Data Field indicated as soon as I turn BRS on.

Init method:

void MX_FDCAN1_Init(void)

{

 hfdcan1.Instance = FDCAN1;

 hfdcan1.Init.ClockDivider = FDCAN_CLOCK_DIV1;

 hfdcan1.Init.FrameFormat = FDCAN_FRAME_FD_BRS;

 hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;

 hfdcan1.Init.AutoRetransmission = ENABLE;

 hfdcan1.Init.TransmitPause = ENABLE;

 hfdcan1.Init.ProtocolException = ENABLE;

 hfdcan1.Init.NominalPrescaler = 1;

 hfdcan1.Init.NominalSyncJumpWidth = 16;

 hfdcan1.Init.NominalTimeSeg1 = 63;

 hfdcan1.Init.NominalTimeSeg2 = 16;

 hfdcan1.Init.DataPrescaler = 1;

 hfdcan1.Init.DataSyncJumpWidth = 4;

 hfdcan1.Init.DataTimeSeg1 = 5;

 hfdcan1.Init.DataTimeSeg2 = 4;

 hfdcan1.Init.StdFiltersNbr = 1;

 hfdcan1.Init.ExtFiltersNbr = 0;

 hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;

 if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)

 {

  Error_Handler();

 }

}

Tx Header:

// /* Prepare Tx Header */

 TxHeader.Identifier = 0x111;

 TxHeader.IdType = FDCAN_STANDARD_ID;

 TxHeader.TxFrameType = FDCAN_DATA_FRAME;

 TxHeader.DataLength = FDCAN_DLC_BYTES_8;

 TxHeader.ErrorStateIndicator = FDCAN_ESI_PASSIVE;

 TxHeader.BitRateSwitch = FDCAN_BRS_ON;

 TxHeader.FDFormat = FDCAN_FD_CAN;

 TxHeader.TxEventFifoControl = FDCAN_NO_TX_EVENTS;

 TxHeader.MessageMarker = 0x55;

Payload:

 Tx_Payload[0] = ubKeyNumber;

 ubKeyNumber=ubKeyNumber+1;

 Tx_Payload[1] = 0x00;

 Tx_Payload[2] = 0x01;

 Tx_Payload[3] = 0x00;

 Tx_Payload[4] = 0x01;

 Tx_Payload[5] = 0x00;

 Tx_Payload[6] = 0x01;

 Tx_Payload[7] = 0x00;

Tried with the ESI_ACTIVE as well.

Anything obvious that anyone can see here?

1 ACCEPTED SOLUTION

Accepted Solutions
HTamh.1
Associate II

Update:

I enabled transmitter delay compensation, and I am adding messages to the TxFIFO every 100ms using a Timer. After adding the compensation, about 500 frames are read by the adapter successfully but then the communication stops abruptly, still showing stuff errors.

 if (HAL_FDCAN_ConfigTxDelayCompensation(&hfdcan1, 5, 0) != HAL_OK)

 {

  Error_Handler();

 }

 if (HAL_FDCAN_EnableTxDelayCompensation(&hfdcan1) != HAL_OK)

 {

  Error_Handler();

 }

View solution in original post

4 REPLIES 4
HTamh.1
Associate II

Update:

I enabled transmitter delay compensation, and I am adding messages to the TxFIFO every 100ms using a Timer. After adding the compensation, about 500 frames are read by the adapter successfully but then the communication stops abruptly, still showing stuff errors.

 if (HAL_FDCAN_ConfigTxDelayCompensation(&hfdcan1, 5, 0) != HAL_OK)

 {

  Error_Handler();

 }

 if (HAL_FDCAN_EnableTxDelayCompensation(&hfdcan1) != HAL_OK)

 {

  Error_Handler();

 }

HTamh.1
Associate II

The issue was more on the PCAN adapter settings after doing the above. The transmitter delay compensation essentially fixed this. Works now.

I am running into similar issues, what did you change on the PCAN side?

HTamh.1
Associate II

Sorry for the late response. I hope your issue is already resolved by now.

I had incorrect bitrate settings for tseg1 and tseg2 at 80Mhzspeed for the fdcan clock. I used this tool https://www.peak-system.com/Bit-Rate-Calculation-Tool.496.0.html?&L=1 to figure out the right parameters for the bit rate registers and then matched them correctly on the firmware and the PCAN software. That was my issue.