2018-07-05 01:42 AM
Greetings everyone,
I encountered a problem with CAN bus during individual work with STM microcontrollers. First of all I would like to give you some information on what I use.
-I am using a microcontroller STM32f091CCTx
-I use CubeMx software.
What I want to do is to view the CAN data from the CAN output of my card with PCAN Viewer.However, I can not get a result despite my long efforts and I open this post to discuss its reasons. First I want to share my CubeMx settings.
I set the PB8 and PB9 outputs to Can Rx and Can Tx in the microcontroller schematic.I have chosen HSE crystal in the RCC as a clock because I have always seen it in similar cases.
When I look at the clock settings, I learned that FCLK is used for the CAN bit rate setting. I set the clock rate to be 36Mhz according to the settings in the prescalar table because the bit rate I want to work is 500kbit/sec.
To adjust the CAN settings, I made the Prescaler settings as seen in the table above.
---------------------------------------------------------------------
After the source code was created, I started coding. I used the HAL library for CAN encoding. The first thing I did was create a variable of type CAN_HandleTypeDef and name it hcan.
Then I made the necessary codings to send the message as below. In this example, ID 0x244 Data was 0x7.
Finally, I sent the message frame using the HAL library(for the transmit) in the main loop at intervals of 100 ms.
Despite all this, I did not find any data on the PCAN Viewer output. The CAN Networks and CAN Loopback examples in st website do not include up-to-date HAL libraries.
Where am I making mistakes. What is missing to send these messages. I will be glad if you help me.
Thanks.
#hal_can_transmit #canbus #hal-libraries #hal-can-driver #cubemx-4.25.1 #hal-li*Solved! Go to Solution.
2018-07-12 07:16 AM
I resolve my problem. My problem is selecting HSE clock as an Crystal Clock ( 2 pin ). My external clock has 1 pin so i changed it as BYPASS clock source and it works!!
2018-07-05 01:44 AM
I forgot the add CAN configurations. I put it below
2018-07-12 07:16 AM
I resolve my problem. My problem is selecting HSE clock as an Crystal Clock ( 2 pin ). My external clock has 1 pin so i changed it as BYPASS clock source and it works!!