cancel
Showing results for 
Search instead for 
Did you mean: 

high speed fdcan stm32g431

Tomuello
Associate II

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello,

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

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
SofLit
ST Employee

Hello,

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

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Tomuello
Associate II

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

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.