Skip to main content
Associate III
April 25, 2025
Solved

CAN in Normal Mode with STM32F407 microcontroller

  • April 25, 2025
  • 1 reply
  • 467 views

Hello everyone,

I'm trying to switch from loopback mode to normal mode. So the program is working perfectly in loopback mode but i had to adapt it so i can use it in the desired normal mode.

I switched to the HSE as a source clock for CAN communication and I'm using PB8 and PB9 for CAN_Tx/Rx.

As a transceiver I'm using the SN65HVD230 with a 120 Ohm terminating resistor and the CANH and CANL are wired correctly to an DB9 connector then to a CAN interface for analyzing.

- I also checked the baud rate and i made sure that there's no mismatch.

- I selected the right channel for the CAN interface

- The transceiver is connected to VDD and GND

- The acceptance filter is configured to let any frame pass through it

- The interruption in the RX is enabled

- The error I'm receiving is an acknowledgment error from the CAN interface

You can find attached my project and i hope you can help me.

Best answer by mƎALLEm

Hello,


@Azizz wrote:

I switched to the HSE as a source clock for CAN communication and I'm using PB8 and PB9 for CAN_Tx/Rx.

As a transceiver I'm using the SN65HVD230 with a 120 Ohm terminating resistor and the CANH and CANL are wired correctly to an DB9 connector then to a CAN interface for analyzing.


Hello,

1- Need to provide more details about the hardware: what board are you using? a sketch to show a complete CAN bus your bard containing the F4 MCU + the transceiver + the CAN bus + the second CAN node (you said CAN interface for analyzing). You need to give details about that "CAN interface for analyzing".

2- Also did you pull the Rs pin of the transceiver down (connected to the GND)?

mALLEm_0-1745592221912.png

The hardware must be 100% OK to establish a good CAN communication.

3- Also please remove the pull-up resistor on the Rx pin:

mALLEm_1-1745592312936.png

4- Please make a photo of your complete setup.

5- I didn't see the declaration of the Rx FIFO0 nor FIFO1 callback in your code:

void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *CanHandle)
void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *CanHandle)

1 reply

mƎALLEm
mƎALLEmAnswer
Technical Moderator
April 25, 2025

Hello,


@Azizz wrote:

I switched to the HSE as a source clock for CAN communication and I'm using PB8 and PB9 for CAN_Tx/Rx.

As a transceiver I'm using the SN65HVD230 with a 120 Ohm terminating resistor and the CANH and CANL are wired correctly to an DB9 connector then to a CAN interface for analyzing.


Hello,

1- Need to provide more details about the hardware: what board are you using? a sketch to show a complete CAN bus your bard containing the F4 MCU + the transceiver + the CAN bus + the second CAN node (you said CAN interface for analyzing). You need to give details about that "CAN interface for analyzing".

2- Also did you pull the Rs pin of the transceiver down (connected to the GND)?

mALLEm_0-1745592221912.png

The hardware must be 100% OK to establish a good CAN communication.

3- Also please remove the pull-up resistor on the Rx pin:

mALLEm_1-1745592312936.png

4- Please make a photo of your complete setup.

5- I didn't see the declaration of the Rx FIFO0 nor FIFO1 callback in your code:

void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *CanHandle)
void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *CanHandle)
To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.