2024-06-21 02:40 AM - last edited on 2024-06-21 03:16 AM by SofLit
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
2024-06-21 02:46 AM - last edited on 2024-06-21 05:05 AM by SofLit
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 */
}
2024-06-21 03:13 AM
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.
2024-06-21 03:28 AM
2024-06-21 03:55 AM
Need to describe your issue and answer all my questions/requests I asked/requested before.
Share also your ioc file.
2024-06-21 04:24 AM
2024-06-21 04:26 AM
2024-06-21 05:04 AM - edited 2024-06-21 05:07 AM
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?
2024-06-21 05:11 AM
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.
2024-06-21 05:57 AM - edited 2024-06-21 06:32 AM
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.