请教关于stm32f4的printf打印输出只输出点不输出数据的问题

2019-07-20 16:06发布

在用f4调串口程序,本来是计算一个程序的执行时间,结果就是单纯的一个简单的printf串口打印输出都有问题,target中的Use Micro LIB选项选了,mian.c文件中包含了stdio.h文件,printf重定向也有了,串口,gpio初始化也有了,但是printf单纯的打印输出一个字符,结果串口看到的就是一个点,对,就是这个  .     郁闷坏了,不知道是什么原因,向大家请教,大家有遇到过这个问题的还请指导一下。   
这是输出结果图:

这是程序:
#include "stm32f4xx.h"#include <stdio.h> void OpenCom(void){ USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);         RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1);         GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9|GPIO_Pin_10; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); USART_InitStructure.USART_BaudRate = BaudRate; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx|USART_Mode_Tx; USART_ITConfig(USART1,USART_IT_RXNE,ENABLE); USART_Init(USART1, &USART_InitStructure);        /* USART configuration */ USART_Cmd(USART1, ENABLE); /* Enable USART */ USART_ClearFlag(USART1, USART_FLAG_TC); NVIC_InitStructure.NVIC_IRQChannel=USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0; NVIC_InitStructure.NVIC_IRQChannelSubPriority=0; NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE; NVIC_Init(&NVIC_InitStructure); }int main(void){   unsigned char i='a';       OpenCom();  printf("%c ",i);       }int fputc(int ch,FILE *f){ USART_SendData(USART1,(unsigned char)ch); while(!(USART1->SR&USART_FLAG_TXE)); return (ch);}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。