cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H723VGT6 FDCAN 0x20 error on trasmission

Angelo3
Associate III

Hi 

I am trying to send some CAN-bus messages from a STM32H723VGT6 mounted on a BIGTREETECH SKR 3 EZ V1.0

I am following this video to send standard CAN messages in external loopback mode (https://www.youtube.com/watch?v=kXyzaaSk6Qs&t=568s&ab_channel=ControllersTech). But whenever I reach the point where I add a message to the TxFifo I get the error 0x20 -> "Parameters error" but I am not sure what could be causing this

Angelo3_0-1731323700247.png

Here are the parameters I set for FDCAN1

Angelo3_1-1731323774525.png

Angelo3_2-1731323798894.png

To avoid additional variables we used the internal clock of the microprocessor, here is the final frequency of the FDcan peripheral

Angelo3_3-1731323888538.png

And the transreceiver mounted on the board is the mcp2542fd-e/sn

 

1 ACCEPTED SOLUTION

Accepted Solutions

1- I don't see a reason to stop the FDCAN after Init:

 

  if(hfdcan1.State != HAL_FDCAN_STATE_READY){
	  HAL_FDCAN_Stop(&hfdcan1);
  }

 

2- From stm32h7xx_hal_fdcan.c:

 

  if (hfdcan->State == HAL_FDCAN_STATE_BUSY)
  {
    /* Check that the Tx FIFO/Queue has an allocated area into the RAM */
    if ((hfdcan->Instance->TXBC & FDCAN_TXBC_TFQS) == 0U)
    {
      /* Update error code */
      hfdcan->ErrorCode |= HAL_FDCAN_ERROR_PARAM;

      return HAL_ERROR;
    }

 

-> As you can see in the comment, you didn't allocate memory into RAM for Tx messages.

You removed the FDCAN Init from the main.c you shared but according to CubeMx Fifo elements number = 0:

SofLit_0-1731331314348.png

You need to set it at least to 1.

 

 

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

11 REPLIES 11
SofLit
ST Employee

Hello,

First, you mentioned you are using this board: 


@Angelo3 wrote:

Hi 

I am trying to send some CAN-bus messages from a STM32H723VGT6 mounted on a BIGTREETECH SKR 3 EZ V1.0


You need to share its schematics.

+ You need to share your code + ioc file.

Second, if you mean by this HSI, that's not recommended if you are using CAN in Normal mode.


@Angelo3 wrote:

To avoid additional variables we used the internal clock of the microprocessor, here is the final frequency of the FDcan peripheral

Angelo3_3-1731323888538.png


And the most important question: did you connect another node on the CAN bus?

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.

Thank you for the quick reply

I attached the schematincs of the board. There is a mistake regarding the pins connected to the canbus peripheral. The correct pins are PA11 and PA12 like the default configuration of FDCAN1 from STCubeIde

I also attached the .ioc file and the main.c file as you requested

Right now we are just testing the board in external loopback mode, do we still need to have another node connected to the bus?

Thank you for the sharing.

According to the schematics, you need to use PB8/PB9 (connected to the tranceiver which is not necessary in LoopBack mode) instead of PA11/PA12 as the latter are used by USB and may external components force the IO levels of the MCU.

SofLit_0-1731326222360.png

SofLit_1-1731326284872.png

 

 

 

 

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.

As I mentioned there is a mistake in the schematics. The pins used for CANbus and USB are swapped

So in the actual board pins PA11/PA12 are actually used for CANbus and PB8/PB9 are used for usb.

We verified this and are 100% sure

Ok, in that case, check this part of schematics with that mechanical switch:

SofLit_0-1731328625125.png

This is not clear to me how it's configured (with the mistake you mentioned). But you need to ensure there is nothing disturbing Tx and Rx pins externally.

PS: I don't see an issue in your code.

 

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.

We didn't design the board, that should just be a jumper to ouput to a type-A usb connector either the canbus or a serial. Activating or deactivating it does not change anything

Do you more specifications about the error I am encoutering? If I look up FDCAN error 0x20 I only get "parameter error" but I think it is more connected to a software issue rahter than hardware

1- I don't see a reason to stop the FDCAN after Init:

 

  if(hfdcan1.State != HAL_FDCAN_STATE_READY){
	  HAL_FDCAN_Stop(&hfdcan1);
  }

 

2- From stm32h7xx_hal_fdcan.c:

 

  if (hfdcan->State == HAL_FDCAN_STATE_BUSY)
  {
    /* Check that the Tx FIFO/Queue has an allocated area into the RAM */
    if ((hfdcan->Instance->TXBC & FDCAN_TXBC_TFQS) == 0U)
    {
      /* Update error code */
      hfdcan->ErrorCode |= HAL_FDCAN_ERROR_PARAM;

      return HAL_ERROR;
    }

 

-> As you can see in the comment, you didn't allocate memory into RAM for Tx messages.

You removed the FDCAN Init from the main.c you shared but according to CubeMx Fifo elements number = 0:

SofLit_0-1731331314348.png

You need to set it at least to 1.

 

 

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.

@Angelo3 wrote:

We didn't design the board, that should just be a jumper to ouput to a type-A usb connector either the canbus or a serial. Activating or deactivating it does not change anything


You didn't design the board but you need to ensure that there is nothing disturbing the Tx and Rx externally and it's up to you to fit/remove the jumper according to this request.

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.

Thank you for the in depth reply

It looks like the cause of the 0x20 error was that we didn't allocate any memory for the tx messages as you pointed out

Right now the board appears to be transmitting and receiving in external loopback mode as we can see from the blinking LEDs we set up. However we tried to connect an oscilloscope to the bus to monitor the waves and we are not able to see the messages that are being sent from the board

To make sure that our setup is working correctly we added another node to the bus and we are able to read its messages correctly (we made sure to have the bus resistance set to 60ohm)

Do you have any idea why the board woud appear to be able to send and receive messages in external loopback mode but we only see radio silece with the oscilloscope?