Skip to main content
GRosi.1
Visitor II
April 20, 2023
Solved

STM32F103C8T6 blue pill CAN does not work

  • April 20, 2023
  • 12 replies
  • 13568 views

I'm trying to send CAN messages with the STM32F103C8T6 microcontroller (blue pill hardware with genuine ST chip) to a CAN analyzer without success.

I'm using STM32CubeIDE v1.12.0. I double checked the hardware, I'm using PB8 and PB9 pins to connect to the CAN transceiver (SN65HVD230 ) RX and TX pin respectively, I have 120 ohm resistor on both CAN line termination, I settled CAN baudrate to different baud but the result is always the same, no pin level changing on TX pin PB9, it remains always at 3.3V (looked with a scope meter), it seems that the CAN cell is not connected to the external pins. I'm not using the USB that is disabled, external 8 MHz crystal with PLL to have 72MHz clock. The code works because I have a LED that correctly toggle its status every 1 second, after a while the CANtransmit function HAL_CAN_AddTxMessage(..) return an error because it doesn't find a free trasmit mailbox. Attached the main function, please help

This topic has been closed for replies.
Best answer by mƎALLEm

Hi,

The value 1 is very small for BS1. Try to select a prescaler value as less as possible and BS1 and BS2 values as greater as possible with BS1 > BS2.

Example:


_legacyfs_online_stmicro_images_0693W00000binswQAA.png

12 replies

mƎALLEm
ST Technical Moderator
April 20, 2023

Hi,

See the thread.

How are you sure it is a genuine ST chip? you can see this link.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Tesla DeLorean
Guru
April 20, 2023

Also CAN/USB can't be used concurrently on these F1 parts

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
APrim.2
Visitor II
April 21, 2023

I answer from another account because the other one (GRosi.1) has problems.

@Community member​ : How are you sure it is a genuine ST chip? =>

  • I asked the seller before to buy if the microcontroller was a genuine ST and he answered it was
  • On the microcontroller there is stamped the model and the ST logo (may be you can understand if the char used is an ST one and/or if the ST logo is correct)
  • I had in the past a blue pill board with a non genuine microcontroller (but the microcontroller was not the STM32F103C8T6) and with the ST LINK it does not connect with the STM32CubeIDE while this one connect and correctly debug with STM32CubeIDE

For this reasons, I thought the chip is a genuine one.

Anyway, have you seen my code? is it correct? if it is supposed to be correct and should work, then for sure I have a counterfait microcontroller.

Is there a check (visual or digital) I can do to understand if the chip is genuine? I attach a picture of the microcontroller. Thank you for your support.

@Community member​ Also CAN/USB can't be used concurrently on these F1 parts => Did you carefully read my previous post? I'm not using the USB that is disabled

Tesla DeLorean
Guru
April 25, 2023

>>Did you carefully read my previous post? I'm not using the USB that is disabled

Generally I just skim things, weighting what is and is not said. The Blue Pill boards are often used with loaders that can/do use USB as a means to get data/applications loaded on them. Assuming you didn't have an ST-LINK attached, as it wasn't mentioned, so also assuming you didn't inspect any of the peripheral registers..

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
mƎALLEm
ST Technical Moderator
April 25, 2023

Hi,

Did you try the Loopback mode before going to Normal mode? If not, I suggest to do it in order to, at least, validate the CAN cell.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
APrim.2
Visitor II
April 25, 2023

Hi, I tested also the loopback mode, silent mode and loopback mode combined with silent mode and it is always the same, no message transmitted/received at all.

mƎALLEm
ST Technical Moderator
April 25, 2023

Could you please share your project in loopback mode (not only the main file) including your IOC file? this helps community members to help you.

Thank you

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
APrim.2
Visitor II
April 25, 2023

Sure, here you have.

Thank you

mƎALLEm
mƎALLEmBest answer
ST Technical Moderator
April 25, 2023

Hi,

The value 1 is very small for BS1. Try to select a prescaler value as less as possible and BS1 and BS2 values as greater as possible with BS1 > BS2.

Example:


_legacyfs_online_stmicro_images_0693W00000binswQAA.png

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
mƎALLEm
ST Technical Moderator
April 25, 2023

You can also try this:


_legacyfs_online_stmicro_images_0693W00000binuJQAQ.png

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
APrim.2
Visitor II
April 25, 2023

The first settings works great!

Thank you very very much!

Best regards

mƎALLEm
ST Technical Moderator
April 25, 2023

Ok great! you're welcome.

I invite you to close this thread by clicking "Select as best" the comment that resolved your issue.

Thank you.

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