2024-03-27 07:15 AM - last edited on 2024-04-04 09:05 AM by SofLit
Hello,
I am using for the first time the FDCAN peripheral.
I have configured it in classic CAN 2.0 mode and I have problems with transmission.
In particular, when I start a transmission, nothing is output on the tx pin, and the TRP field in the FDCAN_TXBRP register remains stuck at 1.
The FDCAN tx/rx pins are connnected to a well terminated bus, where is present another CAN node.
It can't be a bus arbitration problem, because the other CAN node doesn't send messages on the bus by its own.
Any help is really appreciated.
Below is the code snippet that doesn't work.
uint8_t txData[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
fdcan.Instance = FDCAN2;
fdcan.Init.ClockDivider = FDCAN_CLOCK_DIV1;
fdcan.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
fdcan.Init.Mode = FDCAN_MODE_NORMAL;
fdcan.Init.AutoRetransmission = ENABLE;
fdcan.Init.TransmitPause = ENABLE;
fdcan.Init.ProtocolException = DISABLE;
fdcan.Init.NominalPrescaler = 12;
fdcan.Init.NominalSyncJumpWidth = 1;
fdcan.Init.NominalTimeSeg1 = 13;
fdcan.Init.NominalTimeSeg2 = 2;
fdcan.Init.DataPrescaler = 1;
fdcan.Init.DataSyncJumpWidth = 1;
fdcan.Init.DataTimeSeg1 = 1;
fdcan.Init.DataTimeSeg2 = 1;
fdcan.Init.StdFiltersNbr = 1;
fdcan.Init.ExtFiltersNbr = 0;
fdcan.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
HAL_FDCAN_Init(&fdcan);
HAL_FDCAN_Start(&fdcan);
txHeader.Identifier = 0x581;
txHeader.IdType = FDCAN_STANDARD_ID;
txHeader.TxFrameType = FDCAN_DATA_FRAME;
txHeader.DataLength = 8;
txHeader.ErrorStateIndicator = 0;
txHeader.BitRateSwitch = 0;
txHeader.FDFormat = FDCAN_CLASSIC_CAN;
txHeader.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
txHeader.MessageMarker = 0;
HAL_FDCAN_AddMessageToTxFifoQ(&fdcan, &txHeader, &txData[0]);
Regards,
Carlo
Solved! Go to Solution.
2024-04-05 12:31 AM
Hello,
the problem was that I have multiplexed FDCAN_TX / FDCAN_RX to the wrong pins.
Indeed FDCAN_TX / FDCAN_RX can be multiplexed to different pin pairs and when I have activated the FDCAN2 peripheral on CubeMX, it automatically selected the pins pairs multiplexed on FDCAN_TX / FDCAN_RX.
I apologize for not having recognized my mistake before.
Regards,
Carlo
2024-04-04 08:36 AM - edited 2024-04-04 08:39 AM
Hello,
The FDCAN tx/rx pins are connnected to a well terminated bus, where is present another CAN node.
Not sure I understood this statement. What do you mean by "The FDCAN tx/rx pins are connnected to a well terminated bus" ?
Do you mean you did connect FDCAN_TX/FDCAN_RX pins to a termination resistor? Or did you use a CAN transceiver for that? CAN bus is constituted by two wires CAN_HIGH and CAN_LOW transmitting data in differential mode.
Please provide more details about your HW/CAN bus configuration.
2024-04-05 12:31 AM
Hello,
the problem was that I have multiplexed FDCAN_TX / FDCAN_RX to the wrong pins.
Indeed FDCAN_TX / FDCAN_RX can be multiplexed to different pin pairs and when I have activated the FDCAN2 peripheral on CubeMX, it automatically selected the pins pairs multiplexed on FDCAN_TX / FDCAN_RX.
I apologize for not having recognized my mistake before.
Regards,
Carlo