Hello,
I am trying to set up a FDCAN communication (STD Id) at a baud rate of 250 kbit/s in STM32G473RBT .
The Tx part seems to work perfectly but I have a problem at the level of the reception.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-14 4:51 AM
I try to just toggle a led for each received frame (STD ID).
With a logic analyser I checked the Rx pin on the Rx MCU and the frames arrive well. Hence my feeling that the problem lies at the level of the callback function where the MCU never go.
Thank you in advance for the help you will be able to give me.
Solved! Go to Solution.
- Labels:
-
FDCAN
-
STM32G4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-15 8:36 AM
Hi,
You have problem with file "startup_stm32g473rbtx.s". I attached new file for Your project. Please replace only this file.
Best Regards,
Slawek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-14 1:01 PM
Hi,
If You want to have communication 250 kb/s please change in the init section from hfdcan1.Init.NominalPrescaler = 1 to hfdcan1.Init.NominalPrescaler = 4.
Do no not change hfdcan1.Init.ClockDivider. This is divider main clock fequency for FDCAN. If You change this divider You must also change the parameters NominalTimeSeg1 and NominalTimeSeg2.
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 = ENABLE;
hfdcan1.Init.TransmitPause = ENABLE;
hfdcan1.Init.ProtocolException = DISABLE;
hfdcan1.Init.NominalPrescaler = 4;
hfdcan1.Init.NominalSyncJumpWidth = 16;
hfdcan1.Init.NominalTimeSeg1 = 63;
hfdcan1.Init.NominalTimeSeg2 = 16;
hfdcan1.Init.DataPrescaler = 1;
hfdcan1.Init.DataSyncJumpWidth = 4;
hfdcan1.Init.DataTimeSeg1 = 5;
hfdcan1.Init.DataTimeSeg2 = 4;
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 = 0x321;
sFilterConfig.FilterID2 = 0x7FF;
if(HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig) != HAL_OK)
{
Error_Handler();
}
if(HAL_FDCAN_ConfigGlobalFilter(&hfdcan1, FDCAN_REJECT, FDCAN_REJECT, FDCAN_FILTER_REMOTE, FDCAN_FILTER_REMOTE) != HAL_OK)
{
Error_Handler();
}
if(HAL_FDCAN_Start(&hfdcan1) != HAL_OK)
{
Error_Handler();
}
if(HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0) != HAL_OK)
{
Error_Handler();
}
TxHeader.Identifier = 0x123;
TxHeader.IdType = FDCAN_STANDARD_ID;
TxHeader.TxFrameType = FDCAN_DATA_FRAME;
TxHeader.DataLength = FDCAN_DLC_BYTES_8;
TxHeader.ErrorStateIndicator = FDCAN_ESI_ACTIVE;
TxHeader.BitRateSwitch = FDCAN_BRS_OFF;
TxHeader.FDFormat = FDCAN_CLASSIC_CAN;
TxHeader.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
TxHeader.MessageMarker = 0;
/* USER CODE END FDCAN1_Init 2 */
}
Best Regards,
Slawek
Best Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-14 11:17 PM
thank you for your reply but i don't have any problem with the baud rate because i word with 20mhz the clock of FD CAN.i get exactly 250 250 kb/s with the hfdcan1.Init.NominalPrescaler = 1. the problem that i send message from ixxat and there is no receive callback :/. the interruption of FD CAN dosen't work .do you know the reason of that problem !! thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-14 11:35 PM
Hi,
How You check that You do not have receive callback from ixxat?
Please also check settings of Your "sFilterConfig".
Best Regards,
Slawek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-14 11:51 PM
hi,
I tested to place a breakpoint at the beginning of HAL_FDCAN_RxFifo0Callback ;the MCU never go to the call back when i sent a message from ixxat.
Best Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-15 1:03 AM
Hi,
Your device ixxat send message with standardID 0x321 and the lenght is 8 byte?
Best Regards,
Slawek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-15 1:22 AM
YES ; i has verified this with oscilloscope
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-15 5:31 AM
hi;
Now the probleme that when i send message with ixxat standardID 0x321 and the lenght is 8 byte. the MCU go to HardFault_Handler. do you now what can be the probleme please.
Best Regards,
nasri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-15 6:12 AM
Hi,
Please change filter settings from sFilterConfig.FilterID2 = 0x000 to sFilterConfig.FilterID2 = 0x7FF.
Best Regards,
Slawek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-15 6:38 AM
hi;
the same problem HardFault_Handler :\
