Skip to main content
Associate II
February 16, 2025
Solved

CAN AND UART STM32F446RE

  • February 16, 2025
  • 6 replies
  • 1090 views

 

 

HAL_UART_Transmit(&huart2, (uint8_t *)"UART OK\r\n", 9, HAL_MAX_DELAY);

filter_config();

if (HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING | CAN_IT_BUSOFF) != HAL_OK) {
 HAL_UART_Transmit(&huart2, (uint8_t *)"CAN Notification Fail\r\n", 24, HAL_MAX_DELAY);
 Error_Handler();
} else {
 HAL_UART_Transmit(&huart2, (uint8_t *)"CAN Notification OK\r\n", 22, HAL_MAX_DELAY);
}

if(HAL_CAN_Start(&hcan1) != HAL_OK){
 HAL_UART_Transmit(&huart2, (uint8_t *)"CAN NOT START", 16, HAL_MAX_DELAY);
 Error_Handler();
}
else{
 sprintf(msg,"Can start");
 HAL_UART_Transmit(&huart2, (uint8_t *)"Can Start\r\n", 16, HAL_MAX_DELAY);
}

/* USER CODE END 2 */

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
 HAL_UART_Transmit(&huart2, (uint8_t *)"Can Start\r\n", 16, HAL_MAX_DELAY);

 

 


Code formatting applied - please see How to insert source code for future reference.

This topic has been closed for replies.
Best answer by Yakry

clock is the problem

 

and thanks for your reply

6 replies

YakryAuthor
Associate II
February 16, 2025

it cannot show anything in tera term

 

Tesla DeLorean
Guru
February 16, 2025

Likely not an issue with the code shown. Look elsewhere..

Write a subroutine to output strings.

Check the initialization code, pins, etc.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
YakryAuthor
Associate II
February 26, 2025

i check it, the clock is mistaken

, thanks

TDK
February 16, 2025

> STM32F446RE

So probably the NUCLEO-F446RE board?

What pins are you using? Are they connected to what is sending data to tera term?

TDK_1-1739720700535.png

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
YakryAuthorBest answer
Associate II
February 26, 2025

clock is the problem

 

and thanks for your reply

Andrew Neil
Super User
February 17, 2025

Can you get it to work without CAN - ie, a project which does purely UART, and nothing else ?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.