Skip to main content
Visitor II
February 16, 2025
Solved

CAN AND UART STM32F446RE

  • February 16, 2025
  • 3 replies
  • 1049 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

    3 replies

    YakryAuthor
    Visitor II
    February 16, 2025

    it cannot show anything in tera term

     

    Graduate II
    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.

    YakryAuthor
    Visitor II
    February 26, 2025

    i check it, the clock is mistaken

    , thanks

    Super User
    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

     

    YakryAuthorAnswer
    Visitor II
    February 26, 2025

    clock is the problem

     

    and thanks for your reply

    Super User
    February 17, 2025

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