2020-04-07 09:49 AM
Using a Nucleo-H743 board, which unfortunately does not have a FD/CAN example
( https://github.com/STMicroelectronics/STM32CubeH7/tree/master/Projects/NUCLEO-H743ZI/Examples )
But following the code for similar chips, I do see an output on PD1. However it's only ONCE... with nothing attached to the bus, I'd expect retries. Also, if I add another message to the FIFO, it does not send it. The only way to get one output again, is to re-initialize the peripheral.
hfdcan1.Instance = FDCAN1;
hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC; // FDCAN_FRAME_FD_BRS;
hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;
hfdcan1.Init.AutoRetransmission = ENABLE; //**************************
hfdcan1.Init.TransmitPause = DISABLE;
hfdcan1.Init.ProtocolException = ENABLE;
hfdcan1.Init.NominalPrescaler = 0x1; /* tq = NominalPrescaler x (1/fdcan_ker_ck) */
hfdcan1.Init.NominalSyncJumpWidth = 0x10;
hfdcan1.Init.NominalTimeSeg1 = 0x3F;
hfdcan1.Init.NominalTimeSeg2 = 0x10;
hfdcan1.Init.DataPrescaler = 0x1;
hfdcan1.Init.DataSyncJumpWidth = 0x4;
hfdcan1.Init.DataTimeSeg1 = 0xF;
hfdcan1.Init.DataTimeSeg2 = 0x4;
hfdcan1.Init.StdFiltersNbr = 1;
hfdcan1.Init.ExtFiltersNbr = 0;
hfdcan1.Init.RxFifo1ElmtsNbr = 0;
hfdcan1.Init.TxEventsNbr = 0;
HAL_FDCAN_Init(&hfdcan1);
/* Start the FDCAN module */
if (HAL_FDCAN_Start(&hfdcan1) != HAL_OK)
{
/* Start Error */
Error_Handler();
}
if (HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0) != HAL_OK) // Enable Rx Msg Rcvd
{
/* Notification Error */
Error_Handler();
}
TxHeader.Identifier = 0x321;
TxHeader.IdType = FDCAN_STANDARD_ID;
TxHeader.TxFrameType = FDCAN_DATA_FRAME;
TxHeader.DataLength = FDCAN_DLC_BYTES_2;
TxHeader.ErrorStateIndicator = FDCAN_ESI_ACTIVE;
TxHeader.BitRateSwitch = FDCAN_BRS_OFF;
TxHeader.FDFormat = FDCAN_CLASSIC_CAN;
TxHeader.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
TxHeader.MessageMarker = 0;
// Send
if (HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &TxFdMessage.stHeader, TxFdMessage.Data) != HAL_OK)
{
/* Transmission request Error */
Error_Handler();
}
The only clue or error I can see is that the (24kbps) bitrate isn't what I'd expect (1Mbps) based on the FDCLK of 48Mhz.
The DS12923 document says the CAN BOOTLOADER PINS (PH13/Ph14) is FDCAN1, yet the AN4938 document says it is FDCAN2.