Skip to main content
Visitor II
February 13, 2024
Solved

high speed fdcan stm32g431

  • February 13, 2024
  • 2 replies
  • 2059 views

Hi, i'm dealing with fdcan and have problems with high speeds, 1Mbps works good, but 8Mbps (which works in loopback mode) doesn't, I tried with delay compensation, but didn't work, or maybe i used it wrong way?

 

static void MX_FDCAN1_Init(void)

{

 

/* USER CODE BEGIN FDCAN1_Init 0 */

 

/* USER CODE END FDCAN1_Init 0 */

 

/* USER CODE BEGIN FDCAN1_Init 1 */

 

/* USER CODE END FDCAN1_Init 1 */

hfdcan1.Instance = FDCAN1;

hfdcan1.Init.ClockDivider = FDCAN_CLOCK_DIV2;

hfdcan1.Init.FrameFormat = FDCAN_FRAME_FD_BRS;

hfdcan1.Init.Mode = FDCAN_MODE_EXTERNAL_LOOPBACK;

hfdcan1.Init.AutoRetransmission = ENABLE;

hfdcan1.Init.TransmitPause = DISABLE;

hfdcan1.Init.ProtocolException = ENABLE;

hfdcan1.Init.NominalPrescaler = 1;

hfdcan1.Init.NominalSyncJumpWidth = 1;

hfdcan1.Init.NominalTimeSeg1 = 3;

hfdcan1.Init.NominalTimeSeg2 = 3;

hfdcan1.Init.DataPrescaler = 1;

hfdcan1.Init.DataSyncJumpWidth = 3;

hfdcan1.Init.DataTimeSeg1 = 3;

hfdcan1.Init.DataTimeSeg2 = 3;

hfdcan1.Init.StdFiltersNbr = 1;

hfdcan1.Init.ExtFiltersNbr = 0;

hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;

if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)

{

Error_Handler();

}

/* USER CODE BEGIN FDCAN1_Init 2 */

 

FDCAN_FilterTypeDef sFilterConfig;

 

// Configure the filter to accept all messages with Standard ID 0x321

sFilterConfig.IdType = FDCAN_STANDARD_ID;

sFilterConfig.FilterIndex = 0; // Use the first filter bank

sFilterConfig.FilterType = FDCAN_FILTER_MASK; // Specify the filter type

sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0; // Store matching messages in RX FIFO 0

sFilterConfig.FilterID1 = 0x103; // filter

sFilterConfig.FilterID2 = 0x103; // mask

 

 

if (HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig) != HAL_OK) {

// Handle error

}

HAL_FDCAN_ConfigGlobalFilter(&hfdcan1,

FDCAN_REJECT, // Reject non-matching Standard ID messages

FDCAN_REJECT, // Reject non-matching Extended ID messages

FDCAN_REJECT_REMOTE, // Reject remote frames with Standard ID

FDCAN_REJECT_REMOTE); // Reject remote frames with Extended ID

 

/* Configure and enable Tx Delay Compensation : TdcOffset = DataTimeSeg1*DataPrescaler */

HAL_FDCAN_ConfigTxDelayCompensation(&hfdcan1, 3, 0);

HAL_FDCAN_EnableTxDelayCompensation(&hfdcan1);

 

/* USER CODE END FDCAN1_Init 2 */

 

}

 

Tomuello_0-1707842474878.png

 

    This topic has been closed for replies.
    Best answer by mƎALLEm

    Hello,

    Nominal bit time Should not exceed 1Mb/s. Only Data phase could reach 8Mb/s for STM32 MCUs.

    2 replies

    mƎALLEmAnswer
    Technical Moderator
    February 14, 2024

    Hello,

    Nominal bit time Should not exceed 1Mb/s. Only Data phase could reach 8Mb/s for STM32 MCUs.

    TomuelloAuthor
    Visitor II
    February 14, 2024

    Does it mean that only DATA in the frame goes with 8Mbps and other with 1Mbps?

    Technical Moderator
    February 14, 2024

    Yes.

    Nominal phase: max 1Mb/s

    Data phase: max 8Mb/s: this is for STM32. Also it depends on the transceiver bandwidth you're using.