Skip to main content
Associate II
June 21, 2024
Question

NUCLEO-H503RB: FDCAN communication issue

  • June 21, 2024
  • 4 replies
  • 9384 views

I am use nucleo-h503rb evk board and i am configure fdcan communication. I have mention below my code please see. I have did not comes output on FDCAN communication.

 

please send me demo code for that

 

4 replies

Associate II
June 21, 2024
void SystemClock_Config(void)

 

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 = 16;

hfdcan1.Init.NominalSyncJumpWidth = 1;

hfdcan1.Init.NominalTimeSeg1 = 1;

hfdcan1.Init.NominalTimeSeg2 = 1;

hfdcan1.Init.DataPrescaler = 1;

hfdcan1.Init.DataSyncJumpWidth = 1;

hfdcan1.Init.DataTimeSeg1 = 1;

hfdcan1.Init.DataTimeSeg2 = 1;

hfdcan1.Init.StdFiltersNbr = 0;

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 = 0x11;

sFilterConfig.FilterID2 = 0x11;

// sFilterConfig.RxBufferIndex = 0;

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

{

/* Filter configuration Error */

Error_Handler();

}

 

/* USER CODE END FDCAN1_Init 2 */

 

}
mƎALLEm
Technical Moderator
June 21, 2024

Hello and welcome to the community.

First: please read these recommendations on how to post a thread: https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

Second, the issue is not clear. But as you are using Nucleo board? 

I have two questions:

1- Are you using a CAN transceiver? If no .. it couldn't work as you are in Normal mode.

If Yes:

2- Did you connect a second note on the CAN bus? if yes you need to share your schematics/sketch.

Also, I'm no in favor of these parameters of the bit time config:

hfdcan1.Init.NominalPrescaler = 16;
hfdcan1.Init.NominalTimeSeg1 = 1;
hfdcan1.Init.NominalTimeSeg2 = 1;

You need to increase BS1 and BS2 and decrease as much as possible the prescaler. Where the bi time sample point is @ ~(70% to 80%). 

Also you need to use HSE with an external precise source like a crystal in  normal mode.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Associate II
June 21, 2024
  1. I have used transreceiver   (SN65HVD230)
  2. now I have changes as per your guidence butissue has nor resolved hfdcan1.Init.NominalPrescaler = 1; hfdcan1.Init.NominalTimeSeg1 = 8; hfdcan1.Init.NominalTimeSeg2 = 4;
mƎALLEm
Technical Moderator
June 21, 2024

Need to describe your issue and answer all my questions/requests I asked/requested before.

Share also your ioc file.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Associate II
June 21, 2024
mƎALLEm
Technical Moderator
June 21, 2024

Hello,

Thank you. But again you didn't describe the issue. It's an issue on transmit/receive ??

You need to share also the schematics: how you did connect the transceiver? the terminating resistors? Did you connect another node on the bus?

Please answer all these questions in order to help you efficiently.

Also please check each point I raised in my previous comments. dropping some comments increases the ping pongs efficiently. For example In your ioc file Your clock source is set to HSI while in my previous comment I suggested to use HSE with an external precise crystal, did you do that?

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Associate II
June 21, 2024

I have issue transmit data and I have connection below describe

Transreceiver model No- SN65HVD230

1) STM32 CanTx pin connected in Cantransreceiver

2) STM32 CanRX pin connected in Cantarnreceiver

3) Tansreceiver CANH pin connected in DSO Channel 1

4) Tranreceiver CANL pin connected in DSO Channel 2

 

I have connection above 4 points and i was check on DSO but Channel 1 voltage 2.20 and Channel 2 voltage is 2.23 like that. So Differential voltage is 0 and no signal genrate on DSO Screen.

mƎALLEm
Technical Moderator
June 21, 2024

Could you please state what do you mean by DSO? is it an oscilloscope? 

As I stated before, you need at least one other node connected to the bus for acknowledgement mechanism otherwise you don't succeed to transmit CAN frames. CAN is not UART or SPI that you can transmit data without any device connected. To establish a CAN bus you need at least 2 nodes connected to it. This is the CAN basics.

Does the DSO you are talking about has its own internal CAN periph? so you connected NUCLEO-H503 (CAN Node A) to DSO CAN interface (Node B) to establish a CAN bus?

To test CAN interface without a bus communication you can use the Loopback mode.

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Associate II
June 24, 2024

yes, DSO is oscilloscope.

 

Thank you for guiding me. I will test as per your guidance. If issue does not resolve, then I will contact you again.