1 参考:
基于STM32F429-Discovery USART1 PA9 PA10 调试成功
2 运行程序:
STM32Cube_FW_F4_V1.21.0ProjectsSTM32F429I-DiscoveryExamplesUARTUART_TwoBoards_ComPollingMDK-ARM
需要在main.c中设置:
第52行:
#define TRANSMITTER_BOARD
程序运行之后,需要按一下 :USER KEY
while (BSP_PB_GetState(BUTTON_KEY) == RESET)
{
}
之后,才会串口才会打印出信息,串口波特率为9600
**** UART_TwoBoards_ComPolling ****
3 printf
参考网页:
STM32串口通信中使用printf发送数据配置方法(开发环境 Keil RVMDK)
STM32输出调试信息-printf重定向到串口
#include "main.h"
#include "stdio.h"
/** @addtogroup STM32F4xx_HAL_Examples
* @{
*/
/** @addtogroup UART_TwoBoards_ComPolling
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define TRANSMITTER_BOARD
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* UART handler declaration */
UART_HandleTypeDef UartHandle;
int fputc(int ch, FILE *f)
{
HAL_UART_Transmit(&UartHandle, (uint8_t *)&ch,1, 0xFFFF);
return ch;
}
printf("Hello World %drn",1234);
1 参考:
基于STM32F429-Discovery USART1 PA9 PA10 调试成功
2 运行程序:
STM32Cube_FW_F4_V1.21.0ProjectsSTM32F429I-DiscoveryExamplesUARTUART_TwoBoards_ComPollingMDK-ARM
需要在main.c中设置:
第52行:
#define TRANSMITTER_BOARD
程序运行之后,需要按一下 :USER KEY
while (BSP_PB_GetState(BUTTON_KEY) == RESET)
{
}
之后,才会串口才会打印出信息,串口波特率为9600
**** UART_TwoBoards_ComPolling ****
3 printf
参考网页:
STM32串口通信中使用printf发送数据配置方法(开发环境 Keil RVMDK)
STM32输出调试信息-printf重定向到串口
#include "main.h"
#include "stdio.h"
/** @addtogroup STM32F4xx_HAL_Examples
* @{
*/
/** @addtogroup UART_TwoBoards_ComPolling
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define TRANSMITTER_BOARD
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* UART handler declaration */
UART_HandleTypeDef UartHandle;
int fputc(int ch, FILE *f)
{
HAL_UART_Transmit(&UartHandle, (uint8_t *)&ch,1, 0xFFFF);
return ch;
}
printf("Hello World %drn",1234);
举报