cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103C8 CAN transmit using HAL Cube MX and CUBE IDE

VLELE.1
Associate II

Hi all,

I am new to ST.

I am struggling with the attached code.

I am trying to transmit CAN message.

Thanks

3 REPLIES 3
Karl Yamashita
Lead III

You'll need to supply more information/code.

1. How are you checking that you are transmitting? CAN bus analyzer, oscilloscope? Is you hardware connected to another CAN node, with terminating resistor?

2. What baud rate are you running at? You need to supply the code that shows MX_CAN_Init() and relevant code so we can see if the bit timing is correct

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.
VLELE.1
Associate II

Hi Karl,

I am using a DSO as well as CAN tool (PEAK PCAN USB) for checking the messages.

Yes there is 120 ohm termination

I have attached the whole code. [Yes i have named LED-BLINK sorry for that] 

Thanks

Some things i am seeing that are incorrect...

  1. i believe you should call HAL_CAN_Start(&hcan); after you set up the CAN filter.
  2. hcan is already defined in can.c and MX_CAN_Init() is called. So you should be only referring to hcan variable.
  3. You have only 1 can controller and yet i see you defined hcan2. So hcan1 and hcan2 are not valid.

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.