Skip to main content
Visitor II
September 11, 2024
Solved

CAN2 on NUCLEOF446RE is not working.

  • September 11, 2024
  • 6 replies
  • 3839 views

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 

    This topic has been closed for replies.
    Best answer by mƎALLEm

    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.

     

    6 replies

    Technical Moderator
    September 11, 2024

    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.

    pawatJoyAuthor
    Visitor II
    September 11, 2024

    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. 

    Technical Moderator
    September 11, 2024

    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

    pawatJoyAuthor
    Visitor II
    September 11, 2024

    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

     

    pawatJoyAuthor
    Visitor II
    September 11, 2024

    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.

     

    Technical Moderator
    September 11, 2024

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

    Technical Moderator
    September 11, 2024

    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

     

    pawatJoyAuthor
    Visitor II
    September 11, 2024

    I need to desolder my shield. Please wait. I think there might be an issue with my hardware.

    mƎALLEmAnswer
    Technical Moderator
    September 11, 2024

    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.

     

    pawatJoyAuthor
    Visitor II
    September 11, 2024

    After I desoldered the shield connected to the Nucleo board, I found that there was a short circuit on the CAN2 transceiver IC. It works fine now. Thank you for your help, and I apologize for wasting your time.