cancel
Showing results for 
Search instead for 
Did you mean: 

I CANT RECEİVE ANY MESSAGE FROM A CAN BUS ANALYZER WİTH STM32 BOARD

maZers
Associate III

Hello,

I am using stm32F407VGT board and I am trying to receive data from a can analyzer with stm32 board. I transmit a data to stm32 boards but ı cant receive the messages. I can work on normal mode with two stm32 boards succesfully. The messages are received and transmitted. At the same time, I want to transmit data to can analyzer and I want to observe communication. I attached my main and interrupt source files and I am using USB-CAN analyzerV8 device. The can bps values are the same 500kbps. The modes are same as Normal Mode and I dont define a filter so ı can read every data that ı sent from can analyzer  in live expression on debug screen.

Summarize,

All my purpose, I want to see data that ı sent from can analyzer in my live expression part. I am sending one message fisrtly so there is a one Id.

maZers_1-1707850306830.png

 

 

32 REPLIES 32

By the way, If  my can transciever circuit mcp2551 is wrong, How can I communicate with two stm32 board ? Could you show me an example transciever circuit with MCP2551 ? I will use that  

See this thread the picture shared by the community member on his first post.

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.
maZers
Associate III

Thank you 

I changed the terminal resistor with 120ohm on my can circuit and It still doesnt work. I cant understand my boards can communicate but why the analyzer can't ? I attached my can transciever circuit . I changed 60 ohm with 120ohm 

maZers_0-1707929712911.png

 

SofLit
ST Employee

It seems you used "Test circuit" description for your project while this is not the right config:

SofLit_0-1707932476245.png

So is that possible to:

  1. Remove the following capacitors?:
    • The one connected between CAN_H and CAN_L
    • The one connected to Rx pin
  2. Remove the 2.2Kohm resistor and connect RS pin to the ground
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.
maZers
Associate III

maZers_0-1707932544448.png

I tried but it still doesnt work :( I dont know where is the problem. I removed the capacitors except connected +5V one and I connect 120 ohm terminal resistor 

maZers_1-1707933007194.png

I attached my code again. I used callback funcitons this time.

My software purpose's is the received message writed in rcount variable and this data is 1 bit.

You should check for HAL status when HAL_CAN_Start, HAL_CAN_ActivateNotification and 

HAL_CAN_ConfigFilter  are called. Make sure they all return HAL_OK. This way we can eliminate an initialization error, if any.

 

In the Error_Handler you can turn on an LED to indicate any of those 3 calls did not return HAL_OK.

 

  if (HAL_CAN_ConfigFilter(&CanHandle, &sFilterConfig) != HAL_OK)
  {
    /* Filter configuration Error */
    Error_Handler();
  }

  /*##-3- Start the CAN peripheral ###########################################*/
  if (HAL_CAN_Start(&CanHandle) != HAL_OK)
  {
    /* Start Error */
    Error_Handler();
  }

  /*##-4- Activate CAN RX notification #######################################*/
  if (HAL_CAN_ActivateNotification(&CanHandle, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK)
  {
    /* Notification Error */
    Error_Handler();
  }

 

 

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.

thank you for reply

I will try this codes but I have a question 

If I change my can transciever IC MCP2551 with TJA1051,  Can it be better?

Which can transciever IC do you suggest? 

Hello,

If I want to suggest a transceiver, I would choose either a transceiver with 3.3V supply like the ones used on our boards Ex: SN65HVD230.

Or a transceiver having Vio pin like TJA1051T/3 or TJA51TK/3 versions. SofLit_0-1707986367672.png

The transceivers TJA1051 and TJA1051T/E versions are not suitable for you because VIHmin = 0.7xVCC = 3.5V (if VCC=5V). So TX pin needs at least 3.5V > STM32 IO voltage (@3.3V).

MCP2551 still not bad because VIHmin = 2V < 3.3V

 

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.
maZers
Associate III

Hello again,

I readjusted my mcp2551 can transciever circuit and my codes. I attached them. But It still doenst work guys. The prgoram is not getting in canrxfifo ınterrupt function or I cant transmit data to analyzer. Maybe, the analyzer sends hex codes not decimal so can I read hex code data in my live expression panel ? I mean, should I decode  the data in my codes ? 

WhatsApp Image 2024-02-15 at 13.33.14.jpeg

Karl Yamashita
Lead III

Attach your project. Draw up a diagram on how you've connected the MCP2551 to the STM32. How you've connected the CAN analyzer to the MCP2551, including power supply, USB connector(s) and grounds.

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.