使用 nucleo 板中的串行端口usart 2,引脚 2/3来收发数据。接受到数据数量是正确的,打印出字符是错误的,全是“------------------”。消息长度是正确的。 使用 串行监视器,监视的结果,也全是--。 void printMsg(char *msg){ for(uint32_t i = 0; i<strlen(msg); i++) { while((__HAL_UART_GET_FLAG(&huart2, UART_FLAG_TXE) != true)) {} HAL_UART_Transmit(&huart2, (uint8_t)msg, sizeof(msg), HAL_MAX_DELAY); } } sprintf(usr_msg, "This is hello world /n"); printMsg(usr_msg);
|