cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5A9 FDCAN Help

msalgannik
Associate II

I am using a Riverdi STM32 Embedded Display RVT50HQSNWC00-B and having issues with the FDCAN bus. I am capable of writing to the TxFifo and can communicate with an external device in external loop back mode and normal mode. In external and Internal Loop Back Mode, nothing is written to the RxFifo. I am trying to use the board as a receiver not a transmitter. Are there any examples of FDCAN Rx communication with an external device using the STM32U5A9NJH6Q chip. When using CubeMX, there isn't any options for setting RxFifo elements in FDCAN configuration. Does this mean this board cannot be used a reciever, and only can transmit.

1 ACCEPTED SOLUTION

Accepted Solutions

Ok. Did you try the example from STM32U575I-EV\Examples\FDCAN\FDCAN_Loopback\ as it is? is it working well?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

9 REPLIES 9
SofLit
ST Employee

Hello,

Not sure I understood this statement:


and can communicate with an external device in external loop back mode and normal mode. In external and Internal Loop Back Mode, nothing is written to the RxFifo. 

You did succeed to communicate with an external device with a loopback mode? How? 

You need Normal mode for that. Otherwise you need to clarify that point.

Thank you.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Ill try to be more clear.

  • I have successfully used Normal Mode to communicate with an External Device. As in, I am capable of sending a CAN message from the STM32 Embedded Display to my Raspberry Pi v4 with a 2 Channel-CANFD hat.
  • I have not successfully used Restricted-Mode or Bus-Monitoring Mode to receive messages on the STM32 Embedded Display from my Raspberry Pi.
  • In Internal Loopback mode, TxData is not mirrored in RxData. 
 

 

/* Check that the Rx FIFO 0 is not empty */

if ((hfdcan->Instance->RXF0S & FDCAN_RXF0S_F0FL) == 0U)

{

/* Update error code */

hfdcan->ErrorCode |= HAL_FDCAN_ERROR_FIFO_EMPTY;



return HAL_ERROR

 

  • Returns as not empty so continues code
  • RxData value is not the same as TxData. RxData never changes.

I am trying to understand why the RxData is not updating correctly.

CubeMX doesn't allow me to edit any of Rx elements.

msalgannik_0-1718383813975.png

 

Hello,


In Internal Loopback mode, TxData is not mirrored in RxData. 

So if I understood well, even with Loopback mode you didn't succeed to receive messages? in that case drop Normal mode for the moment and let's focus on Loopback mode. Did you configure filters?

 


CubeMX doesn't allow me to edit any of Rx elements.

msalgannik_0-1718383813975.png

 


I need to check internally why there is no Rx FIFO elements setting in the CubeMx. It's true that U5 doesn't have the same FDCAN implementation as H7 for example but anyway I need to check.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Yes you have understood correctly. I will focus on Loopback mode. Could this be a version issue with IDE/TouchGFX/CubeMX?

My configuration for filters is this.

 

 

sFilterConfig.IdType = FDCAN_STANDARD_ID;

sFilterConfig.FilterIndex = 0;

sFilterConfig.FilterType = FDCAN_FILTER_MASK;

sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;

sFilterConfig.FilterID1 = 0x123;

sFilterConfig.FilterID2 = 0x555;

if (HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig) != HAL_OK)

{

/* Filter configuration Error */

Error_Handler();

}

 

Hello,

First, please use <\> button to insert your code for the visibility. See also please refer to these tips to post a thread from here.

Second, I suppose you are trying to receive two IDs: 0x123 and 0x555? right? in that case you need to set filter type to FDCAN_FILTER_DUAL:

 

sFilterConfig.FilterType = FDCAN_FILTER_DUAL;

 

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

I tried this, yet still same result. The RxData never changes from 0. I have been using the STM32U575I-EV FDCAN Loopback Example as a template for how to get this working. This was found in:

\STM32Cube\Repository\STM32Cube_FW_U5_V1.4.0\Projects\STM32U575I-EV\Examples\FDCAN\FDCAN_Loopback\Src

Ok. Did you try the example from STM32U575I-EV\Examples\FDCAN\FDCAN_Loopback\ as it is? is it working well?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

It is working well now with External and Internal Loopback. Thank you. Trying to set the STM32 Embedded Display to receive messages now. I may have questions about that shortly.

Ok good. So please mark the answer that solved your problem as "Accept as solution".

For any other question I invite you to open a new thread.

Thank you :)

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.