AnsweredAssumed Answered

FDCAN STM32H743ZI-NUCLEO TX

Question asked by ab val on Feb 2, 2018
Latest reply on Feb 2, 2018 by ab val

Hi all,

 

I am trying to make a simple CAN test program to send 8 bytes data. 

It seems like it is sending data (from the code point of view) but when I look with a scope. The TX line goes down for a few µS, then go back high and that's it. It seems like it doesn't transmit anything at all....

 

I got the interrupt with  HAL_FDCAN_TxFifoEmptyCallback() called but also the HAL_FDCAN_ErrorCallback()...

 

 

This is the config: 

static void MX_FDCAN1_Init(void)

{

hfdcan1.Instance = FDCAN1;
hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;
hfdcan1.Init.AutoRetransmission = DISABLE;
hfdcan1.Init.TransmitPause = DISABLE;
hfdcan1.Init.NominalPrescaler = 16;
hfdcan1.Init.NominalSyncJumpWidth = 9;
hfdcan1.Init.NominalTimeSeg1 = 4;
hfdcan1.Init.NominalTimeSeg2 = 3;
hfdcan1.Init.DataPrescaler = 4;
hfdcan1.Init.DataSyncJumpWidth = 9;
hfdcan1.Init.DataTimeSeg1 = 4;
hfdcan1.Init.DataTimeSeg2 = 3;
hfdcan1.Init.MessageRAMOffset = 0;
hfdcan1.Init.StdFiltersNbr = 0;
hfdcan1.Init.ExtFiltersNbr = 0;
hfdcan1.Init.RxFifo0ElmtsNbr = 8;
hfdcan1.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan1.Init.RxFifo1ElmtsNbr = 0;
hfdcan1.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan1.Init.RxBuffersNbr = 0;
hfdcan1.Init.RxBufferSize = FDCAN_DATA_BYTES_8;
hfdcan1.Init.TxEventsNbr = 0;
hfdcan1.Init.TxBuffersNbr = 0;
hfdcan1.Init.TxFifoQueueElmtsNbr = 4;
hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
hfdcan1.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
hfdcan1.msgRam.StandardFilterSA = 0;
hfdcan1.msgRam.ExtendedFilterSA = 0;
hfdcan1.msgRam.RxFIFO0SA = 0;
hfdcan1.msgRam.RxFIFO1SA = 0;
hfdcan1.msgRam.RxBufferSA = 0;
hfdcan1.msgRam.TxEventFIFOSA = 0;
hfdcan1.msgRam.TxBufferSA = 0;
hfdcan1.msgRam.TxFIFOQSA = 0;
hfdcan1.msgRam.TTMemorySA = 0;
hfdcan1.msgRam.EndAddress = 0;
hfdcan1.ErrorCode = 0;
if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}

}

 

 

then the code :

HAL_FDCAN_ActivateNotification(&hfdcan1, 0xFFFFFFFF, 0xFFFFFFFF);

/* Start the FDCAN module */
if (HAL_FDCAN_Start(&hfdcan1) != HAL_OK)
{
Error_Handler();
}


/* Prepare Tx Header */
TxHeader.Identifier = 0x1;
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 = 1;
/* USER CODE END 2 */

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{

/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
//if (HAL_FDCAN_AddMessageToTxBuffer(&hfdcan1, &TxHeader, TxData, FDCAN_TX_BUFFER0) != HAL_OK)
if (HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &TxHeader, TxData) != HAL_OK)
{
/* Transmission request Error */
Error_Handler();
}
//if (HAL_FDCAN_EnableTxBufferRequest(&hfdcan1,FDCAN_TX_BUFFER0) != HAL_OK)
{
/* Transmission request Error */
// Error_Handler();
}
HAL_FDCAN_ActivateNotification(&hfdcan1, 0xFFFFFFFF, 0);
HAL_Delay(10);
}

Outcomes