2024-11-11 03:20 AM - last edited on 2024-11-11 03:37 AM by SofLit
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
Here are the parameters I set for FDCAN1
To avoid additional variables we used the internal clock of the microprocessor, here is the final frequency of the FDcan peripheral
And the transreceiver mounted on the board is the mcp2542fd-e/sn
Solved! Go to Solution.
2024-11-11 05:22 AM - edited 2024-11-11 05:26 AM
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:
You need to set it at least to 1.
2024-11-11 03:28 AM
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
And the most important question: did you connect another node on the CAN bus?
2024-11-11 03:38 AM
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?
2024-11-11 03:58 AM - edited 2024-11-11 04:02 AM
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.
2024-11-11 04:33 AM
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
2024-11-11 04:41 AM - edited 2024-11-11 04:45 AM
Ok, in that case, check this part of schematics with that mechanical switch:
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.
2024-11-11 04:58 AM
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
2024-11-11 05:22 AM - edited 2024-11-11 05:26 AM
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:
You need to set it at least to 1.
2024-11-11 05:29 AM
@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.
2024-11-11 06:02 AM
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?