CAN2 on NUCLEOF446RE is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-11 1:35 AM - last edited on ‎2024-09-11 1:49 AM by mƎALLEm
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
Solved! Go to Solution.
- Labels:
-
CAN
-
STM32F4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-11 4:48 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-11 1:53 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-11 1:58 AM - edited ‎2024-09-11 2:09 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-11 2:15 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-11 2:26 AM
here are my transceiver circuits on the shield.
And here is my clock configuration, I use HSI as a clock source.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-11 2:31 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-11 2:56 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-11 3:03 AM
Please compress it in .7z file and attach it by dragging and drop feature. Unfortunately, we don't use google drive.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-11 3:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-11 3:37 AM
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:
