My data are being send in loop despite the datas are ACK.
static void FDCAN_Config(void)
{
FDCAN_FilterTypeDef sFilterConfig;
hfdcan.Instance = FDCAN2;
hfdcan.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
hfdcan.Init.Mode = FDCAN_MODE_NORMAL;
hfdcan.Init.AutoRetransmission = ENABLE;
hfdcan.Init.TransmitPause = ENABLE;
hfdcan.Init.ProtocolException = ENABLE;
hfdcan.Init.NominalPrescaler = 100;
hfdcan.Init.NominalSyncJumpWidth = 0x8;
hfdcan.Init.NominalTimeSeg1 = 0x0D;
hfdcan.Init.NominalTimeSeg2 = 0x2;
hfdcan.Init.MessageRAMOffset = 0;
hfdcan.Init.StdFiltersNbr = 1;
hfdcan.Init.ExtFiltersNbr = 0;
hfdcan.Init.RxFifo0ElmtsNbr = 1;
hfdcan.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan.Init.RxFifo1ElmtsNbr = 1;
hfdcan.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan.Init.RxBuffersNbr = 0;
hfdcan.Init.RxBufferSize = FDCAN_DATA_BYTES_8;
hfdcan.Init.TxEventsNbr = 2;
hfdcan.Init.TxBuffersNbr = 0;
hfdcan.Init.TxFifoQueueElmtsNbr = 2;
hfdcan.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
hfdcan.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
if (HAL_FDCAN_Init(&hfdcan) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
HAL_FDCAN_ConfigGlobalFilter(&hfdcan, FDCAN_ACCEPT_IN_RX_FIFO0, FDCAN_ACCEPT_IN_RX_FIFO0, ENABLE, ENABLE);
/* Configure Rx filter */
sFilterConfig.IdType = FDCAN_STANDARD_ID;
sFilterConfig.FilterIndex = 0;
sFilterConfig.FilterType = FDCAN_FILTER_DUAL;
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO1;
sFilterConfig.FilterID1 = 0x1AA;
sFilterConfig.FilterID2 = 0x72A;
if (HAL_FDCAN_ConfigFilter(&hfdcan, &sFilterConfig) != HAL_OK)
{
/* Filter configuration Error */
Error_Handler();
}
/* Start the FDCAN module */
if (HAL_FDCAN_Start(&hfdcan) != HAL_OK)
{
/* Start Error */
Error_Handler();
}
hfdcan.Instance->IE = 0xFFFFFFFF;
HAL_FDCAN_ConfigInterruptLines(&hfdcan, 0xFFFFFFFF, FDCAN_INTERRUPT_LINE1);
if (HAL_FDCAN_ActivateNotification(&hfdcan, 0x3FFFFFFF, 0) != HAL_OK)
{
/* Notification Error */
Error_Handler();
}
/* Prepare Tx Header */
TxHeader.Identifier = 0x01A;
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;
}
uint8_t BSP_CAN_Send_Data(uint8_t * data)
{
HAL_StatusTypeDef err;
uint32_t interruptRegister;
/* Set the data to be transmitted */
TxData[0] = *data;
TxData[1] = 0xAE;
TxData[0] = *data;
TxData[1] = 0xAD;
/* Start the Transmission process */
err = HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan, &TxHeader, TxData);
if (err != HAL_OK)
{
/* Transmission request Error */
printf("error HAL_FDCAN_AddMessageToTxFifoQ %d\r\n", err);
HAL_Delay(3000);
Error_Handler();
}
}
void BSP_CAN_Test()
{
uint8_t data = 0;
while (1)
{
BSP_CAN_Send_Data(&data);
HAL_Delay(3000);
while (HAL_FDCAN_GetTxFifoFreeLevel(&hfdcan) != 2)
{
HAL_Delay(100); // Stuck here as data is not considered send
}
data++;
}
}Hello,
I do have some issue having my FDCAN bus up and running. I am using STM32H750 IC with MCP2542 CAN transceiver chip. I am trying to communicate with another device on the CAN bus. I am debuggging the bus with a salae device both RxD/TxD and CANH/CANL.
I do see my data sending out and data from the other device coming in on the bus.
Here is the problem.
My data are being send in a loop despite the fact there are ACK on the bus.
I configure all interruption, and enable all callback, none is trigger except when after a long time when I deInit/Reinit the FDCAN module. In this case, TXEmpty callback is called.
I try to unplug the other device and run in Internal or External loopback mode, but it is exactly the same thing. No callback, no error, but my data being send in loop.
The other problem I am facing, is that I am enable to receive the keepalive send by the other module on the bus. I have tried so many configuration of the filters that I am pretty sure it is not the issue. Does not work in loopback mode too.
I may have miss something huge, so if you can help.
My starting code is based on the FDCAN example Classic mode of the STM32H743I_EVAL Cube example code.
Here is an extract of my code, excluded of the GPIO configuration.
