Skip to main content
Visitor II
October 15, 2025
Solved

Trouble configuring FDCAN on STM32G473 to communicate with Arduino MCP2515 (CAN 2.0)

  • October 15, 2025
  • 2 replies
  • 789 views

Hi everyone,

We’re currently developing an OBD reader using an STM32G473, which includes three FDCAN controllers. Each FDCAN interface is connected to a TCAN3413 transceiver.

As part of our testing setup, we built an ECU simulator using an Arduino with an MCP2515 controller and a TJA1050 transceiver, and this simulator works perfectly.

However, we’re facing a major issue when trying to send CAN requests from our STM32-based board to this ECU simulator. We’re not able to make the FDCAN controller operate in Classical CAN 2.0 mode and send messages correctly.

We verified this by checking both the RX and CAN lines of the transceiver with an oscilloscope. The TX signal from the STM32 does not show the expected data pattern.
That said, the transceiver itself is working correctly, when we send data from the Arduino node, the RX pin on the transceiver shows a clean, valid CAN signal. The issue seems to be that the STM32’s FDCAN controller doesn’t properly interpret or transmit standard CAN 2.0 frames, and as a result, we can’t see any valid messages on the microcontroller side.

To make it easier to understand our setup, we’re attaching several images:

  • Our clock configuration from STM32CubeMX
  • The main.c source file
  • The FDCAN1 peripheral configuration we’re currently using

We’d really appreciate any help or insight from the community on how to correctly configure the FDCAN peripheral on the STM32G473 to work in standard CAN 2.0 mode, compatible with MCP2515-based nodes.

Thanks in advance for any advice or configuration examples you can share!

WhatsApp Image 2025-10-15 at 5.53.58 PM.jpeg

WhatsApp Image 2025-10-15 at 5.53.58 PM (1).jpeg

 

/* USER CODE BEGIN Header */
/**
 ******************************************************************************
 * @file : main.c
 * @brief : Main program body
 ******************************************************************************
 * @attention
 *
 * Copyright (c) 2025 STMicroelectronics.
 * All rights reserved.
 *
 * This software is licensed under terms that can be found in the LICENSE file
 * in the root directory of this software component.
 * If no LICENSE file comes with this software, it is provided AS-IS.
 *
 ******************************************************************************
 */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
FDCAN_HandleTypeDef hfdcan1;
FDCAN_HandleTypeDef hfdcan2;

I2C_HandleTypeDef hi2c2;

/* USER CODE BEGIN PV */

FDCAN_TxHeaderTypeDef TxHeader;
FDCAN_RxHeaderTypeDef RxHeader;
FDCAN_TxHeaderTypeDef TxHeader2;
FDCAN_RxHeaderTypeDef RxHeader2;

uint8_t TxData[8];
uint8_t RxData[8];

uint8_t txData[4] = { 0x10, 0x20, 0x30, 0x40 };
uint8_t rxData[4];

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_FDCAN1_Init(void);
static void MX_FDCAN2_Init(void);
static void MX_I2C2_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
 * @brief The application entry point.
 * @retval int
 */
int main(void)
{

 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();

 /* USER CODE BEGIN Init */

 /* USER CODE END Init */

 /* Configure the system clock */
 SystemClock_Config();

 /* USER CODE BEGIN SysInit */

 /* USER CODE END SysInit */

 /* Initialize all configured peripherals */
 MX_GPIO_Init();
 MX_FDCAN1_Init();
 MX_FDCAN2_Init();
 MX_I2C2_Init();
 /* USER CODE BEGIN 2 */

	//HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
	// Iniciar FDCAN
	if (HAL_FDCAN_Start(&hfdcan1) != HAL_OK) {
		Error_Handler();
	}
	if (HAL_FDCAN_Start(&hfdcan2) != HAL_OK) {
		Error_Handler();
	}

	// Activar notificación de mensajes recibidos
	//if (HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0) != HAL_OK) {
	//	Error_Handler();
	//}

	if (HAL_FDCAN_ActivateNotification(&hfdcan2, FDCAN_IT_RX_FIFO1_NEW_MESSAGE, 0) != HAL_OK) {
		Error_Handler();
	}

	// Configuración Tx Header
	TxHeader.Identifier = 0x123;
	TxHeader.IdType = FDCAN_STANDARD_ID;
	TxHeader.TxFrameType = FDCAN_DATA_FRAME;
	TxHeader.DataLength = FDCAN_DLC_BYTES_8; // 8 bytes de datos
	TxHeader.ErrorStateIndicator = FDCAN_ESI_ACTIVE;
	TxHeader.BitRateSwitch = FDCAN_BRS_OFF; // Data phase más rápida
	TxHeader.FDFormat = FDCAN_CLASSIC_CAN; // CAN-clasico
	TxHeader.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
	TxHeader.MessageMarker = 0;

	// Mensaje inicial
	for (uint8_t i = 0; i < 8; i++)
		TxData[i] = i;

	// Transmitir mensaje
	if (HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &TxHeader, TxData) != HAL_OK) {
		Error_Handler();
	}

 /* USER CODE END 2 */

 /* Infinite loop */
 /* USER CODE BEGIN WHILE */
	while (1) {
		HAL_Delay(1000);

		for (uint8_t i = 0; i < 8; i++)
			TxData[i]++;

		HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &TxHeader, TxData);
		//HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan2, &TxHeader, TxData);
		//HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_3);

		//if (HAL_I2C_Master_Transmit(&hi2c2, (0x54 << 1), txData, sizeof(txData), HAL_MAX_DELAY) == HAL_OK) {
		//	HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_3);
		//}

		//HAL_Delay(500);

		// Leer 4 bytes desde el esclavo
		//if (HAL_I2C_Master_Receive(&hi2c2, (0x54 << 1), rxData, sizeof(rxData), HAL_MAX_DELAY) == HAL_OK) {
		//	HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_3);
		//}

		//HAL_Delay(500);
 /* USER CODE END WHILE */

 /* USER CODE BEGIN 3 */
	}
 /* USER CODE END 3 */
}

/**
 * @brief System Clock Configuration
 * @retval None
 */
void SystemClock_Config(void)
{
 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

 /** Configure the main internal regulator output voltage
 */
 HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);

 /** Initializes the RCC Oscillators according to the specified parameters
 * in the RCC_OscInitTypeDef structure.
 */
 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
 RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4;
 RCC_OscInitStruct.PLL.PLLN = 25;
 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
 RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV6;
 RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
 {
 Error_Handler();
 }

 /** Initializes the CPU, AHB and APB buses clocks
 */
 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
 |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
 {
 Error_Handler();
 }
}

/**
 * @brief FDCAN1 Initialization Function
 * @PAram None
 * @retval None
 */
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_DIV1;
 hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
 hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;
 hfdcan1.Init.AutoRetransmission = DISABLE;
 hfdcan1.Init.TransmitPause = DISABLE;
 hfdcan1.Init.ProtocolException = DISABLE;
 hfdcan1.Init.NominalPrescaler = 1;
 hfdcan1.Init.NominalSyncJumpWidth = 13;
 hfdcan1.Init.NominalTimeSeg1 = 86;
 hfdcan1.Init.NominalTimeSeg2 = 13;
 hfdcan1.Init.DataPrescaler = 25;
 hfdcan1.Init.DataSyncJumpWidth = 1;
 hfdcan1.Init.DataTimeSeg1 = 2;
 hfdcan1.Init.DataTimeSeg2 = 1;
 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;

	sFilterConfig.IdType = FDCAN_STANDARD_ID;
	sFilterConfig.FilterIndex = 0;
	sFilterConfig.FilterType = FDCAN_FILTER_MASK;
	sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
	sFilterConfig.FilterID1 = 0x000;
	sFilterConfig.FilterID2 = 0x7ff;

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

 /* USER CODE END FDCAN1_Init 2 */

}

/**
 * @brief FDCAN2 Initialization Function
 * @PAram None
 * @retval None
 */
static void MX_FDCAN2_Init(void)
{

 /* USER CODE BEGIN FDCAN2_Init 0 */

 /* USER CODE END FDCAN2_Init 0 */

 /* USER CODE BEGIN FDCAN2_Init 1 */

 /* USER CODE END FDCAN2_Init 1 */
 hfdcan2.Instance = FDCAN2;
 hfdcan2.Init.ClockDivider = FDCAN_CLOCK_DIV1;
 hfdcan2.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
 hfdcan2.Init.Mode = FDCAN_MODE_NORMAL;
 hfdcan2.Init.AutoRetransmission = DISABLE;
 hfdcan2.Init.TransmitPause = DISABLE;
 hfdcan2.Init.ProtocolException = DISABLE;
 hfdcan2.Init.NominalPrescaler = 1;
 hfdcan2.Init.NominalSyncJumpWidth = 13;
 hfdcan2.Init.NominalTimeSeg1 = 86;
 hfdcan2.Init.NominalTimeSeg2 = 13;
 hfdcan2.Init.DataPrescaler = 25;
 hfdcan2.Init.DataSyncJumpWidth = 1;
 hfdcan2.Init.DataTimeSeg1 = 2;
 hfdcan2.Init.DataTimeSeg2 = 1;
 hfdcan2.Init.StdFiltersNbr = 1;
 hfdcan2.Init.ExtFiltersNbr = 0;
 hfdcan2.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
 if (HAL_FDCAN_Init(&hfdcan2) != HAL_OK)
 {
 Error_Handler();
 }
 /* USER CODE BEGIN FDCAN2_Init 2 */
	FDCAN_FilterTypeDef sFilterConfig;

	sFilterConfig.IdType = FDCAN_STANDARD_ID;
	sFilterConfig.FilterIndex = 0;
	sFilterConfig.FilterType = FDCAN_FILTER_MASK;
	sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO1;
	sFilterConfig.FilterID1 = 0x000;
	sFilterConfig.FilterID2 = 0x7ff;

	if (HAL_FDCAN_ConfigFilter(&hfdcan2, &sFilterConfig) != HAL_OK) {
		Error_Handler();
	}

 /* USER CODE END FDCAN2_Init 2 */

}

/**
 * @brief I2C2 Initialization Function
 * @PAram None
 * @retval None
 */
static void MX_I2C2_Init(void)
{

 /* USER CODE BEGIN I2C2_Init 0 */

 /* USER CODE END I2C2_Init 0 */

 /* USER CODE BEGIN I2C2_Init 1 */

 /* USER CODE END I2C2_Init 1 */
 hi2c2.Instance = I2C2;
 hi2c2.Init.Timing = 0x10805D88;
 hi2c2.Init.OwnAddress1 = 0;
 hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
 hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
 hi2c2.Init.OwnAddress2 = 0;
 hi2c2.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
 hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
 hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
 if (HAL_I2C_Init(&hi2c2) != HAL_OK)
 {
 Error_Handler();
 }

 /** Configure Analogue filter
 */
 if (HAL_I2CEx_ConfigAnalogFilter(&hi2c2, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
 {
 Error_Handler();
 }

 /** Configure Digital filter
 */
 if (HAL_I2CEx_ConfigDigitalFilter(&hi2c2, 0) != HAL_OK)
 {
 Error_Handler();
 }
 /* USER CODE BEGIN I2C2_Init 2 */

 /* USER CODE END I2C2_Init 2 */

}

/**
 * @brief GPIO Initialization Function
 * @PAram None
 * @retval None
 */
static void MX_GPIO_Init(void)
{
 GPIO_InitTypeDef GPIO_InitStruct = {0};
 /* USER CODE BEGIN MX_GPIO_Init_1 */

 /* USER CODE END MX_GPIO_Init_1 */

 /* GPIO Ports Clock Enable */
 __HAL_RCC_GPIOF_CLK_ENABLE();
 __HAL_RCC_GPIOA_CLK_ENABLE();
 __HAL_RCC_GPIOC_CLK_ENABLE();
 __HAL_RCC_GPIOB_CLK_ENABLE();

 /*Configure GPIO pin Output Level */
 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_11|GPIO_PIN_12
 |GPIO_PIN_15, GPIO_PIN_RESET);

 /*Configure GPIO pin : PA2 */
 GPIO_InitStruct.Pin = GPIO_PIN_2;
 GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 /*Configure GPIO pins : PA3 PA5 PA11 */
 GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_11;
 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 /*Configure GPIO pin : PA4 */
 GPIO_InitStruct.Pin = GPIO_PIN_4;
 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 /*Configure GPIO pin : PA9 */
 GPIO_InitStruct.Pin = GPIO_PIN_9;
 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 /*Configure GPIO pins : PA12 PA15 */
 GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_15;
 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 /* USER CODE BEGIN MX_GPIO_Init_2 */

 /* USER CODE END MX_GPIO_Init_2 */
}

/* USER CODE BEGIN 4 */
/*
void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs) {
	if ((RxFifo0ITs & FDCAN_IT_RX_FIFO0_NEW_MESSAGE) != 0) {
		if (HAL_FDCAN_GetRxMessage(hfdcan, FDCAN_RX_FIFO0, &RxHeader, RxData)
				== HAL_OK) {
			HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_3); // Ejemplo: toggle LED en PA3
		}
	}
}*/

void HAL_FDCAN_RxFifo1Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo1ITs) {
	if ((RxFifo1ITs & FDCAN_IT_RX_FIFO1_NEW_MESSAGE) != 0) {
		if (HAL_FDCAN_GetRxMessage(hfdcan, FDCAN_RX_FIFO1, &RxHeader, RxData) == HAL_OK) {
			HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_3);
		}
	}
}
/* USER CODE END 4 */

/**
 * @brief This function is executed in case of error occurrence.
 * @retval None
 */
void Error_Handler(void)
{
 /* USER CODE BEGIN Error_Handler_Debug */
	/* User can add his own implementation to report the HAL error return state */
	__disable_irq();
	while (1) {
	}
 /* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
 * @brief Reports the name of the source file and the source line number
 * where the assert_param error has occurred.
 * @PAram file: pointer to the source file name
 * @PAram line: assert_param error line source number
 * @retval None
 */
void assert_failed(uint8_t *file, uint32_t line)
{
 /* USER CODE BEGIN 6 */
 /* User can add his own implementation to report the file name and line number,
 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
 /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

 

    This topic has been closed for replies.
    Best answer by Onlywavesmdp

    Hi, sorry for the delay. We were able to solve the problem it actually wasn’t related to the STM configuration. The issue was with the ECU simulator, where a wrong setting caused it to send data at a baud rate of 1 Mb/s instead of 500 kb/s. Once that was fixed, both boards were able to communicate correctly.

    Thanks a lot for your help and guidance!

    2 replies

    Technical Moderator
    October 15, 2025

    Hello @Onlywavesmdp and welcome to the ST community

    1- Please attach your ioc file

    2- You need also to share the schematics

    3- Did you try the External Loopback mode? 

     

    Technical Moderator
    October 15, 2025

    Question: why FDCAN clock > System clock frequency?

    mALLEm_0-1760567941563.png

    Increase the system clock. Let's say the max frequency at 170MHz using the PLL and keep the FDCAN clock set at 50MHz.

    Visitor II
    October 16, 2025

    Hi @mƎALLEm , here I’m attaching the .ioc file.

    #MicroXplorer Configuration settings - do not modify
    CAD.formats=
    CAD.pinconfig=
    CAD.provider=
    FDCAN1.AutoRetransmission=DISABLE
    FDCAN1.CalculateBaudRateNominal=500000
    FDCAN1.CalculateTimeBitNominal=2000
    FDCAN1.CalculateTimeQuantumNominal=20.0
    FDCAN1.DataPrescaler=25
    FDCAN1.DataSyncJumpWidth=1
    FDCAN1.DataTimeSeg1=2
    FDCAN1.DataTimeSeg2=1
    FDCAN1.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,AutoRetransmission,NominalSyncJumpWidth,DataPrescaler,DataSyncJumpWidth,DataTimeSeg1,DataTimeSeg2,NominalPrescaler,NominalTimeSeg1,NominalTimeSeg2,Mode,StdFiltersNbr
    FDCAN1.Mode=FDCAN_MODE_NORMAL
    FDCAN1.NominalPrescaler=1
    FDCAN1.NominalSyncJumpWidth=13
    FDCAN1.NominalTimeSeg1=86
    FDCAN1.NominalTimeSeg2=13
    FDCAN1.StdFiltersNbr=1
    FDCAN2.AutoRetransmission=DISABLE
    FDCAN2.CalculateBaudRateNominal=500000
    FDCAN2.CalculateTimeBitNominal=2000
    FDCAN2.CalculateTimeQuantumNominal=20.0
    FDCAN2.DataPrescaler=25
    FDCAN2.DataSyncJumpWidth=1
    FDCAN2.DataTimeSeg1=2
    FDCAN2.DataTimeSeg2=1
    FDCAN2.IPParameters=CalculateTimeQuantumNominal,CalculateTimeBitNominal,CalculateBaudRateNominal,AutoRetransmission,TransmitPause,NominalSyncJumpWidth,DataPrescaler,DataTimeSeg1,DataTimeSeg2,NominalPrescaler,NominalTimeSeg1,NominalTimeSeg2,ProtocolException,Mode,DataSyncJumpWidth,StdFiltersNbr
    FDCAN2.Mode=FDCAN_MODE_NORMAL
    FDCAN2.NominalPrescaler=1
    FDCAN2.NominalSyncJumpWidth=13
    FDCAN2.NominalTimeSeg1=86
    FDCAN2.NominalTimeSeg2=13
    FDCAN2.ProtocolException=DISABLE
    FDCAN2.StdFiltersNbr=1
    FDCAN2.TransmitPause=DISABLE
    File.Version=6
    GPIO.groupedBy=Group By Peripherals
    I2C2.IPParameters=Timing
    I2C2.Timing=0x10805D88
    KeepUserPlacement=false
    Mcu.CPN=STM32G473CEU3
    Mcu.Family=STM32G4
    Mcu.IP0=FDCAN1
    Mcu.IP1=FDCAN2
    Mcu.IP2=I2C2
    Mcu.IP3=NVIC
    Mcu.IP4=RCC
    Mcu.IP5=SYS
    Mcu.IPNb=6
    Mcu.Name=STM32G473C(B-C-E)Ux
    Mcu.Package=UFQFPN48
    Mcu.Pin0=PF0-OSC_IN
    Mcu.Pin1=PF1-OSC_OUT
    Mcu.Pin10=PA12
    Mcu.Pin11=PA13
    Mcu.Pin12=PA14
    Mcu.Pin13=PA15
    Mcu.Pin14=PB5
    Mcu.Pin15=PB6
    Mcu.Pin16=PB8-BOOT0
    Mcu.Pin17=PB9
    Mcu.Pin18=VP_SYS_VS_Systick
    Mcu.Pin19=VP_SYS_VS_DBSignals
    Mcu.Pin2=PA2
    Mcu.Pin3=PA3
    Mcu.Pin4=PA4
    Mcu.Pin5=PA5
    Mcu.Pin6=PC4
    Mcu.Pin7=PA8
    Mcu.Pin8=PA9
    Mcu.Pin9=PA11
    Mcu.PinsNb=20
    Mcu.ThirdPartyNb=0
    Mcu.UserConstants=
    Mcu.UserName=STM32G473CEUx
    MxCube.Version=6.15.0
    MxDb.Version=DB.6.0.150
    NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
    NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
    NVIC.FDCAN1_IT0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
    NVIC.FDCAN2_IT0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
    NVIC.ForceEnableDMAVector=true
    NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
    NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
    NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
    NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
    NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
    NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
    NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
    NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
    PA11.Locked=true
    PA11.Signal=GPIO_Output
    PA12.GPIOParameters=GPIO_PuPd,GPIO_ModeDefaultOutputPP
    PA12.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_OD
    PA12.GPIO_PuPd=GPIO_NOPULL
    PA12.Locked=true
    PA12.Signal=GPIO_Output
    PA13.Locked=true
    PA13.Mode=Serial_Wire
    PA13.Signal=SYS_JTMS-SWDIO
    PA14.Locked=true
    PA14.Mode=Serial_Wire
    PA14.Signal=SYS_JTCK-SWCLK
    PA15.GPIOParameters=GPIO_PuPd,GPIO_ModeDefaultOutputPP
    PA15.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_OD
    PA15.GPIO_PuPd=GPIO_NOPULL
    PA15.Locked=true
    PA15.Signal=GPIO_Output
    PA2.Locked=true
    PA2.Signal=GPXTI2
    PA3.GPIOParameters=GPIO_PuPd,GPIO_ModeDefaultOutputPP
    PA3.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
    PA3.GPIO_PuPd=GPIO_NOPULL
    PA3.Locked=true
    PA3.Signal=GPIO_Output
    PA4.Locked=true
    PA4.Signal=S_TIM3_CH2
    PA5.Locked=true
    PA5.Signal=GPIO_Output
    PA8.GPIOParameters=GPIO_Speed
    PA8.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
    PA8.Locked=true
    PA8.Mode=I2C
    PA8.Signal=I2C2_SDA
    PA9.Locked=true
    PA9.Signal=ADC5_IN2
    PB5.GPIOParameters=GPIO_Speed,GPIO_PuPd
    PB5.GPIO_PuPd=GPIO_PULLUP
    PB5.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
    PB5.Mode=FDCAN_Activate
    PB5.Signal=FDCAN2_RX
    PB6.GPIOParameters=GPIO_Speed
    PB6.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
    PB6.Locked=true
    PB6.Mode=FDCAN_Activate
    PB6.Signal=FDCAN2_TX
    PB8-BOOT0.GPIOParameters=GPIO_Speed,GPIO_PuPd
    PB8-BOOT0.GPIO_PuPd=GPIO_PULLUP
    PB8-BOOT0.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
    PB8-BOOT0.Mode=FDCAN_Activate
    PB8-BOOT0.Signal=FDCAN1_RX
    PB9.GPIOParameters=GPIO_Speed,GPIO_PuPd
    PB9.GPIO_PuPd=GPIO_NOPULL
    PB9.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
    PB9.Locked=true
    PB9.Mode=FDCAN_Activate
    PB9.Signal=FDCAN1_TX
    PC4.GPIOParameters=GPIO_Speed
    PC4.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH
    PC4.Locked=true
    PC4.Mode=I2C
    PC4.Signal=I2C2_SCL
    PF0-OSC_IN.Locked=true
    PF0-OSC_IN.Mode=HSE-External-Oscillator
    PF0-OSC_IN.Signal=RCC_OSC_IN
    PF1-OSC_OUT.Locked=true
    PF1-OSC_OUT.Mode=HSE-External-Oscillator
    PF1-OSC_OUT.Signal=RCC_OSC_OUT
    PinOutPanel.RotationAngle=0
    ProjectManager.AskForMigrate=true
    ProjectManager.BackupPrevious=false
    ProjectManager.CompilerLinker=GCC
    ProjectManager.CompilerOptimize=6
    ProjectManager.ComputerToolchain=false
    ProjectManager.CoupleFile=false
    ProjectManager.CustomerFirmwarePackage=
    ProjectManager.DefaultFWLocation=true
    ProjectManager.DeletePrevious=true
    ProjectManager.DeviceId=STM32G473CEUx
    ProjectManager.FirmwarePackage=STM32Cube FW_G4 V1.6.1
    ProjectManager.FreePins=false
    ProjectManager.HalAssertFull=false
    ProjectManager.HeapSize=0x200
    ProjectManager.KeepUserCode=true
    ProjectManager.LastFirmware=true
    ProjectManager.LibraryCopy=1
    ProjectManager.MainLocation=Core/Src
    ProjectManager.NoMain=false
    ProjectManager.PreviousToolchain=
    ProjectManager.ProjectBuild=false
    ProjectManager.ProjectFileName=FirmwareCanXplorer.ioc
    ProjectManager.ProjectName=FirmwareCanXplorer
    ProjectManager.ProjectStructure=
    ProjectManager.RegisterCallBack=
    ProjectManager.StackSize=0x400
    ProjectManager.TargetToolchain=STM32CubeIDE
    ProjectManager.ToolChainLocation=
    ProjectManager.UAScriptAfterPath=
    ProjectManager.UAScriptBeforePath=
    ProjectManager.UnderRoot=true
    ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_FDCAN1_Init-FDCAN1-false-HAL-true,4-MX_FDCAN2_Init-FDCAN2-false-HAL-true,5-MX_I2C2_Init-I2C2-false-HAL-true
    RCC.ADC12Freq_Value=48000000
    RCC.ADC345Freq_Value=48000000
    RCC.AHBFreq_Value=48000000
    RCC.APB1Freq_Value=48000000
    RCC.APB1TimFreq_Value=48000000
    RCC.APB2Freq_Value=48000000
    RCC.APB2TimFreq_Value=48000000
    RCC.CRSFreq_Value=48000000
    RCC.CortexFreq_Value=48000000
    RCC.EXTERNAL_CLOCK_VALUE=12288000
    RCC.FCLKCortexFreq_Value=48000000
    RCC.FDCANCLockSelection=RCC_FDCANCLKSOURCE_PLL
    RCC.FDCANFreq_Value=50000000
    RCC.FamilyName=M
    RCC.HCLKFreq_Value=48000000
    RCC.HRTIM1Freq_Value=48000000
    RCC.HSE_VALUE=48000000
    RCC.HSI48_VALUE=48000000
    RCC.HSI_VALUE=16000000
    RCC.I2C1Freq_Value=48000000
    RCC.I2C2Freq_Value=48000000
    RCC.I2C3Freq_Value=48000000
    RCC.I2C4Freq_Value=48000000
    RCC.I2SFreq_Value=48000000
    RCC.IPParameters=ADC12Freq_Value,ADC345Freq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CRSFreq_Value,CortexFreq_Value,EXTERNAL_CLOCK_VALUE,FCLKCortexFreq_Value,FDCANCLockSelection,FDCANFreq_Value,FamilyName,HCLKFreq_Value,HRTIM1Freq_Value,HSE_VALUE,HSI48_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,I2C4Freq_Value,I2SFreq_Value,LPTIM1Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,PLLM,PLLN,PLLPoutputFreq_Value,PLLQ,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PLLSourceVirtual,PWRFreq_Value,QSPIFreq_Value,RNGFreq_Value,SAI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value
    RCC.LPTIM1Freq_Value=48000000
    RCC.LPUART1Freq_Value=48000000
    RCC.LSCOPinFreq_Value=32000
    RCC.LSE_VALUE=32768
    RCC.LSI_VALUE=32000
    RCC.MCO1PinFreq_Value=16000000
    RCC.PLLM=RCC_PLLM_DIV4
    RCC.PLLN=25
    RCC.PLLPoutputFreq_Value=150000000
    RCC.PLLQ=RCC_PLLQ_DIV6
    RCC.PLLQoutputFreq_Value=50000000
    RCC.PLLRCLKFreq_Value=150000000
    RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE
    RCC.PWRFreq_Value=48000000
    RCC.QSPIFreq_Value=48000000
    RCC.RNGFreq_Value=50000000
    RCC.SAI1Freq_Value=48000000
    RCC.SYSCLKFreq_VALUE=48000000
    RCC.SYSCLKSource=RCC_SYSCLKSOURCE_HSE
    RCC.UART4Freq_Value=48000000
    RCC.USART1Freq_Value=48000000
    RCC.USART2Freq_Value=48000000
    RCC.USART3Freq_Value=48000000
    RCC.USBFreq_Value=50000000
    RCC.VCOInputFreq_Value=12000000
    RCC.VCOOutputFreq_Value=300000000
    SH.GPXTI2.0=ADC3_EXTI2
    SH.GPXTI2.1=ADC5_EXTI2
    SH.GPXTI2.ConfNb=2
    SH.S_TIM3_CH2.0=TIM3_CH2
    SH.S_TIM3_CH2.ConfNb=1
    VP_SYS_VS_DBSignals.Mode=DisableDeadBatterySignals
    VP_SYS_VS_DBSignals.Signal=SYS_VS_DBSignals
    VP_SYS_VS_Systick.Mode=SysTick
    VP_SYS_VS_Systick.Signal=SYS_VS_Systick
    board=custom
    isbadioc=false

    I’m also including the schematic of the board. Both the EQ simulator made with Arduino and the development board itself have a 120 Ω termination resistor connected.

    In this case, even though the 120 Ω resistor doesn’t appear in the schematic, it is connected in parallel between CAN H and CAN L.

    The transceiver configuration and its connection to the STM were made according to the specifications described in their respective datasheets. The standby/mode pins have their corresponding logic levels set so that the transceiver operates correctly. The 3.3 V supply for the STM is provided directly by the ST-Link programmer.

    Onlywavesmdp_0-1760578706193.png

    Regarding your question about the external loopback mode: yes, we tested it using the same code. In our code, a red LED on the board turns on whenever a valid frame is received. When we run the system in external loopback mode, that red LED keeps blinking constantly, indicating that frames are being received correctly.

    However, since external loopback mode allows us to observe the signal from the controller’s TX pin, we connected the oscilloscope and noticed that the waveform looks quite odd compared to when we send a CAN frame from the EQ simulator. The CAN signal we observe at the transceiver’s RX pin is completely different in timing compared to the signal seen at the TX pin when using external loopback mode.

    As for the FDCAN clock frequency in relation to the system clock frequency, that was just part of our testing. We tried multiple frequency values, some lower than the system clock. For example, we tested the FDCAN clock at 8 MHz while the system clock was at 48 MHz, but the system still didn’t work.

    Thanks a lot for your quick reply and for taking the time to help!

    OnlywavesmdpAuthorAnswer
    Visitor II
    October 22, 2025

    Hi, sorry for the delay. We were able to solve the problem it actually wasn’t related to the STM configuration. The issue was with the ECU simulator, where a wrong setting caused it to send data at a baud rate of 1 Mb/s instead of 500 kb/s. Once that was fixed, both boards were able to communicate correctly.

    Thanks a lot for your help and guidance!

    Technical Moderator
    October 22, 2025

    @Onlywavesmdp wrote:

    Hi, sorry for the delay. We were able to solve the problem it actually wasn’t related to the STM configuration. The issue was with the ECU simulator, where a wrong setting caused it to send data at a baud rate of 1 Mb/s instead of 500 kb/s. Once that was fixed, both boards were able to communicate correctly.

    Thanks a lot for your help and guidance!


    That's why for CAN/FDCAN subjects you need to provide details about all nodes connected on the bus ;)