cancel
Showing results for 
Search instead for 
Did you mean: 

CAN2 on NUCLEOF446RE is not working.

pawatJoy
Associate II

I am working on NUCLEO F446RE, I need to use CAN1 and CAN2 on the STM32 NUCLEO-F446RE board. I tested CAN1, which works normally for sending and receiving data, but when I tried CAN2, it didn’t work at all. I looked for solutions in https://community.st.com/t5/stm32-mcus-products/how-to-configure-can-filters-to-use-can1-and-can2-parallelly/td-p/56553?attachment-id=595  and https://community.st.com/t5/stm32-mcus/stm32-in-dual-can-configuration-bxcan-filter-bank-explanation/ta-p/698739 , but CAN2 still doesn’t work. here is my code 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello,

I've created a project with CAN1 and CAN2 are communicating together on NUCLEO F446RE in Normal mode using two MCP2561 transceivers and the communication is working well. I didn't change any SB solder bridge on the board.

I'm using Interrupts instead of polling. In CubeIDE See live expression CAN1_RxData[] and CAN2_RxData[]: the data are changing. CAN1 is sending data to CAN2 and vice versa.

Use the attached project and connect CAN1 to CAN2. Remove the other nucleo from the bus and get back to me with the result.

Hope it helps.

 

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.

View solution in original post

12 REPLIES 12
SofLit
ST Employee

Hello @pawatJoy and welcome to the community.

You need to describe what the example is doing because I didn't understand from the code you shared what do you want to do.

  while (1)
  {
    /* USER CODE END WHILE */

	 //HAL_CAN_AddTxMessage(&hcan1, &txHeader, txData, &txMailbox);
	 HAL_CAN_AddTxMessage(&hcan2, &txHeader, txData, &txMailbox);
	 HAL_CAN_GetRxMessage(&hcan2, CAN_RX_FIFO0, &rxHeader, rxData);
	 HAL_UART_Transmit(&huart2, rxData, 8, 100);
	  // Check FIFO0
//	 if (HAL_CAN_GetRxFifoFillLevel(&hcan1, CAN_RX_FIFO0) > 0)
//	 {
//		 HAL_CAN_GetRxMessage(&hcan1, CAN_RX_FIFO0, &rxHeader, rxData);
//		 //HAL_UART_Transmit(&huart2, rxData, 8, 100);
//		 // Process received data from FIFO0
//	 }

	 HAL_Delay(1000);
  }
  /* USER CODE END 3 */
}

Is there something connected on the CAN bus apart of NUCLEO F446RE? or connected CAN1 and CAN2 together?

So we need to have a full picture of your example.

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.
pawatJoy
Associate II

Hi,

i tested each can bus by using 2 nucleo boards (with the same code) to communicate through CANBUS. Each board connects to the shield. There are two CAN Transceivers on there. In the while loop, they both send the message to each other, read the received message, and then print it out through UART2. The CAN1 works correctly but CAN2 does not. 

Yes but need to provide more details about the HW.

Is is the same transceiver used for CAN1 and CAN2? 

Need to provide more details to have full picture to help you efficiently.

PS: I don't see issues with Filters config. 

Except the fact that you are using HSI as source clock for CAN in NORMAL mode.

Also refer to this article: https://community.st.com/t5/stm32-mcus/can-reception-issues-reasons-and-general-troubleshooting/ta-p/689741

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.

here are my transceiver circuits on the shield. 

pawatJoy_2-1726046658306.png

And here is my clock configuration, I use HSI as a clock source.

pawatJoy_3-1726046752074.png

 

Could you please attach your two projects (including the ioc files): 

NUCLEOF446RE/ CAN2 and the project of second node attached to the bus.

Thank you.

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.
pawatJoy
Associate II

I have only one project for my two boards. Here is my project (I can not send the zip file here) https://drive.google.com/file/d/1CAcsMcvFjsGo4sZ1yrjvcO9jvUJBJ8_Z/view?usp=sharing . I tested with can1 and it worked fine, but when I changed to CAN2 it did not work.

 

Please compress it in .7z file and attach it by dragging and drop feature. Unfortunately, we don't use google drive.

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.
pawatJoy
Associate II
 

Could you please change the CAN2_Rx/Tx pins from PB12/PB13 to respectively PB5/PB6.

I have a doubt regarding the solder bridges config:

SofLit_0-1726050984989.png

 

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.