Showing results for 
Search instead for 
Did you mean: 

Unable to transmit CAN signal on Bluepill.

Associate III

I am transmitting a CAN signal using bluepill but there is no signal on the CAN Bus. I added two counters which will check whether transmission was successful with the following code.

if(HAL_CAN_AddTxMessage(&hcan, &TxHeader, TxData, &TxMailbox) == HAL_OK){
  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 0);
} else {
  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 1);

The transmitCount is increasing till 19 everytime, and then failCount starts to increase.

This is not happening always, sometimes it works properly, sometimes it causes issue. I currently have 2 bluepills, this issue is happening in one and the other is working properly. but earlier, both bluepills were working.

I have made the CAN bus hardware as stable as possible to eliminate any loose connections. So loose connection is highly unlikely. They why might it be behaving differently everytime? Why is it increasing till exactly 19 everytime?

I have attached the full project, ioc file and main.c file with this question.


ST Employee

No original STM32F103s have been used on Bluepill for a long time, only counterfeits. Please read my replies to this and that thread, maybe some things will become clearer to you.

The cheapest way out would be to desolder the fakes and solder on original STM32F103C8T6, alternatively you can use a suitable NUCLEO board and be happy with it.

Good luck!


In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
ST Employee


As stated by @Peter BENSCH we are not confident about the chip used on Black/Blue pill boards as they are most fake. Additionally, many community members encountered issues with CAN when using these boards.

You can purchase any of ST boards: Nucleo for example and attach a CAN transceiver in Normal mode where another node is attached to the bus. In loopback mode no need for a transceiver.

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

What's the error? Understand WHAT the HAL is complaining about, when not HAL_OK, perhaps dig into instance looking for ErrorCode type detail. Add optional instrumentation so the software can report failure in a way that you can readily see what's happening, and if failure is cascading.

The FIFO isn't deep, and the CAN peripheral needs to see other devices, and those need to acknowledge acceptance so the pending message can be retired.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

What else is connected to the CAN BUS? ,else it will stop sending. Or as explained above try loopback