cancel
Showing results for 
Search instead for 
Did you mean: 

FDCAN STM32H743ZI-NUCLEO (Transmit Problem)

Moha-Affa
Associate II

Hello,

i am trying to write a small example which only send 8 bytes .

I am using generated code from Stm32cubeMx and i have the initialization parameter from this thread :

https://community.st.com/s/question/0D50X00009XkWmjSAF/fdcan-stm32h743zinucleo-tx

I am using msp2517fd transceiver.

what do i miss ?

the initialization :

hfdcan1.Instance = FDCAN1;
  hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
  hfdcan1.Init.Mode = FDCAN_MODE_INTERNAL_LOOPBACK;
  hfdcan1.Init.AutoRetransmission = DISABLE;
  hfdcan1.Init.TransmitPause = DISABLE;
  hfdcan1.Init.ProtocolException = 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 = 11;
  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();
  }
  /* USER CODE BEGIN FDCAN1_Init 2 */
 
  /* USER CODE END FDCAN1_Init 2 */
 
}

/* Prepare Tx Header */

pTxHeader.Identifier = 0xaa;
 
 
pTxHeader.IdType = FDCAN_STANDARD_ID;
 
 
pTxHeader.TxFrameType = FDCAN_DATA_FRAME;
 
 
pTxHeader.DataLength = FDCAN_DLC_BYTES_8;
 
 
pTxHeader.ErrorStateIndicator = FDCAN_ESI_ACTIVE;
 
 
pTxHeader.BitRateSwitch = FDCAN_BRS_OFF;
 
 
pTxHeader.FDFormat = FDCAN_CLASSIC_CAN;
 
 
pTxHeader.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
 
 
pTxHeader.MessageMarker = 1;

the main :

HAL_Init();
 
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
 
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
	
  MX_FDCAN1_Init();
  /* USER CODE BEGIN 2 */
	for( int i = 0 ; i < 8 ; i++)
		pTxData[i] = i ;
	//	HAL_FDCAN_ActivateNotification(&hfdcan1, 0xFFFFFFFF, 0xFFFFFFFF);
 
/* Start the FDCAN module */
 
 
 
if (HAL_FDCAN_Start(&hfdcan1) != HAL_OK)
 
 
{
 
 
Error_Handler();
 
 
}
 
if (HAL_FDCAN_AddMessageToTxBuffer(&hfdcan1, &pTxHeader, pTxData, FDCAN_TX_BUFFER0) != HAL_OK)
 
 
//if (HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &pTxHeader, pTxData) != HAL_OK)
 
 
{
 
 
/* Transmission request Error */
 
 
Error_Handler();
 
 
}
 
 
if (HAL_FDCAN_EnableTxBufferRequest(&hfdcan1,FDCAN_TX_BUFFER0) != HAL_OK)
 
 
{
 
 
/* Transmission request Error */
 
 
//Error_Handler();
 
 
}

any ideas ??

1 REPLY 1
Moha-Affa
Associate II

is the function HAL_FDCAN_EnableTxBufferRequest used to put the data from FDCAN_TX_BUFFER0 on Bus or i see this wrong ??