Skip to main content
ab val
Associate III
February 2, 2018
Solved

FDCAN STM32H743ZI-NUCLEO TX

  • February 2, 2018
  • 6 replies
  • 1972 views
Posted on February 02, 2018 at 12:34

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);

}

#fdcan-stm32h7
This topic has been closed for replies.
Best answer by ab val
Posted on February 02, 2018 at 16:01

It is fixed now and working. The issue was the 5V not being properly connected on the MCP2542 click...

6 replies

ab val
ab valAuthor
Associate III
February 2, 2018
Posted on February 02, 2018 at 12:37

Why the source code formatting thing is not working ??

ab val
ab valAuthor
Associate III
February 2, 2018
Posted on February 02, 2018 at 12:51

The error function is called with Protocol Error in Arbitration Phase.

Any idea why this would happen ?

Tesla DeLorean
Guru
February 2, 2018
Posted on February 02, 2018 at 13:06

Do you have a transceiver looping back rx? How about a bus and another device to receive and acknowledge the completed packet?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
ab val
ab valAuthor
Associate III
February 2, 2018
Posted on February 02, 2018 at 13:17

I have a MCP2542 click connected to my nucleo and muxtrace to receive the packet.

But nothing. The fact that I got the interrupt error means that there must be something wrong with my can parameters.

ab val
ab valAuthor
Associate III
February 2, 2018
Posted on February 02, 2018 at 14:23

I am using the demo code in

STM32Cube_FW_H7_V1.2.0\Projects\STM32H743I_EVAL\Examples\FDCAN\FDCAN_Classic_Frame_Networking

But I have the same issue, it doesn't send and I got the same error...

ab val
ab valAuthorBest answer
Associate III
February 2, 2018
Posted on February 02, 2018 at 16:01

It is fixed now and working. The issue was the 5V not being properly connected on the MCP2542 click...