cancel
Showing results for 
Search instead for 
Did you mean: 

FDCAN setup on Riverdi display STM32H757XIH6

AlexandreTe
Associate II

Hi everyone,

I bought a display Riverdi display (RVT70HSSNWC00-B) with a STM32H757XIH6 microcontroller.

I want to setup the FDCAN but without success.

Has anybody already done and could send a sample ?

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Souhaib MAZHOUD
ST Employee

Hi @AlexandreTe 

Thank you for posting!.

You can check out this video FDCAN Normal Operating Mode - YouTube  for an exemple of FDCAN configuration with STM32H7.  

And i advise to refer this document Introduction to FDCAN peripherals for STM32 product classes - Application note, it will give you an overview of FDCAN peripherals for STM32.

Thank you.

Souhaib

 

View solution in original post

10 REPLIES 10
Souhaib MAZHOUD
ST Employee

Hi @AlexandreTe 

Thank you for posting!.

You can check out this video FDCAN Normal Operating Mode - YouTube  for an exemple of FDCAN configuration with STM32H7.  

And i advise to refer this document Introduction to FDCAN peripherals for STM32 product classes - Application note, it will give you an overview of FDCAN peripherals for STM32.

Thank you.

Souhaib

 

Hi Souhaib,

Thank you for your reply.

I watch the video you have sent,after that sending message works but receive not works.

Have you got a project which works with the riverdi product ?

 

Thank you.

 

Alexandre

Issamos
Lead II

Hello @AlexandreTe 

I think this two articles could help you (with video demonstration).

Hope this is helpful for you. If your question is answered please check this answer as best answer to be diffused.

Best regards.

II

Hi Issamos,

Thank you for your reply.

Finally, I find what to change using the code provide by ST. It is just a little bit different using touchgfx.

I close this subject.

Sasa1234
Associate II

Hi all,

I want to know if I have to supply FD CAN transciever in order to work correctly with it.

Thank you again.

Hi, I have the same problem with fdcan, I send it but I can't receive anything. Can you tell me what needs to be changed in the code? I use riverdi lcd with stm32 board.

Many Thanks

Hi,

Did you respect this structure ?

AlexandreTe_3-1716791342545.png

 

From the display :

AlexandreTe_1-1716791310669.png

 

To the display :

AlexandreTe_2-1716791321979.png

 

 

Hello, thanks for the answer, yes, the MCU GUI communication is correct. You probably looked at my post, there is some code removed. I create a new empty project and just try to run CAN. To send and receive something. The settings are as follows and it neither sends nor receives data (callback does not work).

FDCAN is default 40Mhz, RTC -> Bypass


I would like to ask a huge request if you could send me your project by e-mail only with FdCan support, it would make it much easier for me.   lcdk@lcdk.pl

 

 

void MX_FDCAN1_Init(void)
{
  hfdcan1.Instance = FDCAN1;
  //hfdcan1.Init.FrameFormat = FDCAN_FRAME_FD_NO_BRS;
  //hfdcan1.Init.Mode = FDCAN_MODE_EXTERNAL_LOOPBACK;  //I try too
  hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
  hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;
  hfdcan1.Init.AutoRetransmission = ENABLE;
  hfdcan1.Init.TransmitPause = DISABLE;
  hfdcan1.Init.ProtocolException = DISABLE;
  hfdcan1.Init.NominalPrescaler = 1;
  hfdcan1.Init.NominalSyncJumpWidth = 10; //ok
  hfdcan1.Init.NominalTimeSeg1 = 69;
  hfdcan1.Init.NominalTimeSeg2 = 10;
  hfdcan1.Init.DataPrescaler = 20; //ok
  hfdcan1.Init.DataSyncJumpWidth = 1; //ok
  hfdcan1.Init.DataTimeSeg1 = 2; //ok
  hfdcan1.Init.DataTimeSeg2 = 1; //ok
  hfdcan1.Init.MessageRAMOffset = 0;
  hfdcan1.Init.StdFiltersNbr = 1;
  hfdcan1.Init.ExtFiltersNbr = 0;
  hfdcan1.Init.RxFifo0ElmtsNbr = 1; //ok
  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 = 1; //ok
  hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
  hfdcan1.Init.TxElmtSize = FDCAN_DATA_BYTES_8;

  if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)
  {
    Error_Handler();
  }
  FDCAN_FilterTypeDef canfilterconfig;

  canfilterconfig.IdType = FDCAN_STANDARD_ID;
  canfilterconfig.FilterIndex = 0;
  canfilterconfig.FilterType = FDCAN_FILTER_MASK; //FDCAN_FILTER_RANGE
  canfilterconfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
  canfilterconfig.FilterID1 = 0x100;
  canfilterconfig.FilterID2 = 0x100;
  canfilterconfig.RxBufferIndex = 0;

  if (HAL_FDCAN_ConfigFilter(&hfdcan1, &canfilterconfig) != HAL_OK)
  {
    /* Filter configuration Error */
    Error_Handler();
  }

  HAL_FDCAN_ConfigGlobalFilter(&hfdcan1, FDCAN_REJECT, FDCAN_REJECT, FDCAN_REJECT_REMOTE, FDCAN_REJECT_REMOTE);

}

void HAL_FDCAN_MspInit(FDCAN_HandleTypeDef* fdcanHandle)
{
   // Default code (...)
   /* FDCAN1 interrupt Init */
    HAL_NVIC_SetPriority(FDCAN1_IT0_IRQn, 5, 0);
    HAL_NVIC_EnableIRQ(FDCAN1_IT0_IRQn);
  }
}


Main.C

void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs)
{
    HAL_FDCAN_GetRxMessage(hfdcan, FDCAN_RX_FIFO0, &RxHeader, RxData);
    if (RxHeader.DataLength == 8)
    {
    	datacheck = 1;
    }

}

  if (HAL_FDCAN_Start(&hfdcan1) != HAL_OK)
  {
    Error_Handler();
  }

  if (HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0) != HAL_OK)
  {
    Error_Handler();
  }

  TxHeader.Identifier = 0x10;
  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_FD_CAN;//FDCAN_CLASSIC_CAN;
  TxHeader.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
  TxHeader.MessageMarker = 0;

  /* Init scheduler */
  osKernelInitialize();


void Sent()
{
          TxData[0] = 0x10;
	  TxData[1] = 0x20;
	  TxData[2] = 0x30;
	  TxData[3] = 0x40;
	  TxData[4] = 0x50;
	  TxData[5] = 0x60;
	  TxData[6] = 0x70;
	  TxData[7] = 0x80;
	  if (HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &TxHeader, TxData) != HAL_OK)
	  {
	 	Error_Handler();
	  }
}

 

 

 

Ok i add more can device to bus and now i can send message. But when i send message to riverdi stm32. The program stops and enters such a loop. I have absolutely no idea why. Instead of executing the interrupt HAL_FDCAN_RxFifo0Callback, it enters an infinite loop.

 

 

/**
 * @brief  This is the code that gets called when the processor receives an
 *         unexpected interrupt.  This simply enters an infinite loop, preserving
 *         the system state for examination by a debugger.
 *   None
 * @retval None
*/
    .section  .text.Default_Handler,"ax",%progbits
Default_Handler:
Infinite_Loop:
  b  Infinite_Loop
  .size  Default_Handler, .-Default_Handler

 

And Error

WWDG_RST_IRQHandler() at startup_stm32h747xihx.s:113 0x8003490