2024-02-15 11:45 AM - last edited on 2024-02-16 12:25 AM by SofLit
Hello,
I've started to develop with the Riverdi STM32 Embedded Display and I'm trying to use the CAN BUS to display data, but unfortunately I can't. I'm not receiving any data. The CAN on the board is a FDCAN and I've set it to classic, because that's the function I need to use. I'm not receiving any data. The baud rate is set to 500kbit/s as I need it, but whatever I send to the board via the CAN BUS, I'm not receiving it. I need to receive from any CAN BUS ID. I'm also trying to find information on how to send data properly between the Main -> model. I've found some information but it's 2-3 years old and I could use a little more help.
Thanks a lot.
Solved! Go to Solution.
2024-02-19 05:22 AM
yes, i'm very sure that it's not the hardware, but the software that's the problem. the board i use is the one from Riverdi. I tested the components that could be faulty and everything was ok. So I know and I'm convinced that my problem is software
My point was regarding the wires not the components. At least did you check the continuity between the two transceivers: CAN_H and CAN_L also the termination resistor of 120 ohm connected to the bus.
So please check the two points and get back with the results.
2024-02-19 05:27 AM
yes, I've got my two 120ohm termination resistors and my CAN_L and CAN_H are well connected. there's no need to worry about that.
2024-02-19 10:01 AM
I've managed to solve my problem and I've retrieved the error code and it's a HAL_FDCAN_ERROR_PARAM
Now I just need to find the right parameters
#include "fdcan.h"
//* USER CODE BEGIN 0 */
FDCAN_TxHeaderTypeDef TxHeader;
__IO uint32_t Notification_flag = 0;
__IO uint32_t Transmission_flag = 0;
/* USER CODE END 0 */
FDCAN_HandleTypeDef hfdcan1;
FDCAN_HandleTypeDef hfdcan2;
/* FDCAN1 init function */
void MX_FDCAN1_Init(void) {
/* USER CODE BEGIN FDCAN1_Init 0 */
FDCAN_FilterTypeDef sFilterConfig;
/* USER CODE END FDCAN1_Init 0 */
/* USER CODE BEGIN FDCAN1_Init 1 */
/* USER CODE END FDCAN1_Init 1 */
hfdcan1.Instance = FDCAN1;
hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;
hfdcan1.Init.AutoRetransmission = DISABLE;
hfdcan1.Init.TransmitPause = DISABLE;
hfdcan1.Init.ProtocolException = DISABLE;
hfdcan1.Init.NominalPrescaler = 1;
hfdcan1.Init.NominalSyncJumpWidth = 13;
hfdcan1.Init.NominalTimeSeg1 = 65;
hfdcan1.Init.NominalTimeSeg2 = 14;
hfdcan1.Init.DataPrescaler = 25;
hfdcan1.Init.DataSyncJumpWidth = 1;
hfdcan1.Init.DataTimeSeg1 = 2;
hfdcan1.Init.DataTimeSeg2 = 1;
hfdcan1.Init.MessageRAMOffset = 0;
hfdcan1.Init.StdFiltersNbr = 1;
hfdcan1.Init.ExtFiltersNbr = 0;
hfdcan1.Init.RxFifo0ElmtsNbr = 0;
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 = 0;
hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
hfdcan1.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN FDCAN1_Init 2 */
/* Configure Rx filter */
sFilterConfig.IdType = FDCAN_STANDARD_ID;
sFilterConfig.FilterIndex = 0;
sFilterConfig.FilterType = FDCAN_FILTER_MASK;
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
sFilterConfig.FilterID1 = 0x0;
sFilterConfig.FilterID2 = 0x0;
if (HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig) != HAL_OK) {
/* Filter configuration Error */
Error_Handler();
}
/* Configure global filter to reject all non-matching frames */
HAL_FDCAN_ConfigGlobalFilter(&hfdcan1, FDCAN_REJECT, FDCAN_REJECT,
FDCAN_REJECT_REMOTE, FDCAN_REJECT_REMOTE);
/* Configure Rx FIFO 0 watermark to 2 */
HAL_FDCAN_ConfigFifoWatermark(&hfdcan1, FDCAN_CFG_RX_FIFO0, 2);
/* Activate Rx FIFO 0 watermark notification */
HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO0_WATERMARK, 0);
/* Prepare Tx Header */
TxHeader.Identifier = 0x111;
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_ON;
TxHeader.FDFormat = FDCAN_CLASSIC_CAN;
TxHeader.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
TxHeader.MessageMarker = 0;
HAL_NVIC_SetPriority(FDCAN1_IT0_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(FDCAN1_IT0_IRQn);
HAL_FDCAN_Stop(&hfdcan1);
HAL_FDCAN_Start(&hfdcan1);
/* USER CODE END FDCAN1_Init 2 */
}
2024-02-19 11:46 AM
>Now I just need to find the right parameters
Great! Use the debugger, step into HAL_FDCAN_Init and find where it returns the error.
2024-02-20 06:19 AM
thanks everyone, i found the problem after doing some other research, the buffer for fifo0 must be setter
hfdcan1.Init.RxFifo0ElmtsNbr = 1; // 1 is the minimum that must be for it to receive data in the FIFO0 otherwise param error and nothing enters.
2024-03-29 10:43 AM
I also started the development with an embedded Riverdi STM32 display. In the example from TouchGFX, all peripherals are configured on one M7 core.
Are you using two cores in your development? Did you manage to configure the core-M4?