Skip to main content
Slee.13
Associate
April 20, 2022
Question

stm32f103 CAN send fail...

  • April 20, 2022
  • 1 reply
  • 695 views

hi there.

I'm trying to CAN transmit on my target board.

my board is not to send CAN message on stm32cubeide . but I confirmed that my board send CAN message on mbed.

Can I how to send CAN message on stm32cubeide?? 

I intended CAN baudrate 500kbps, sampling point 75% and my apb1 clock is 18Mhz, HSE is 8Mhz, and my crystal is 8Mhz.

below is printf() debug message when my board running and stop.

Always debug message show me the message such as below..

<Can Send Success: 1

<Can Send Success: 2

<Can Send Success: 3

<Can Send Success: 4

<Can Send Success: 5

<Can Send Success: 6

<Can Send Success: 7

<Can Send Success: 8

<Can Send Success: 9

<Can Send Success: 10

<Can Send Success: 11

<Can Send Success: 12

<Can Send Success: 13

<Can Send Success: 14

<Can Send Success: 15

<Can Send Success: 16

<Can Send Success: 17

<Can Send Success: 18

<Can Send Success: 19

<Can Send Fail

my source code attached .

please check my error...

regards..

This topic has been closed for replies.

1 reply

mƎALLEm
ST Technical Moderator
September 23, 2026

Hello,

I’m pretty sure it’s the bit timing configuration related issue.

You have this configuration:

  hcan.Init.Prescaler = 9;
hcan.Init.TimeSeg1 = CAN_BS1_2TQ;
hcan.Init.TimeSeg2 = CAN_BS2_1TQ;

Please avoid low BS1 and BS2 values. So increase them while decreasing the CAN prtescaler.

Some users faced the same issue while using a such low values for BS1 and BS2.

So I suggest you to refer to this knowledge base article on how to configure the CAN bit time for STM32:

It already mentioned that note:

Hope that helps you as well as others ..
 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.