OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 5674|回复: 2

printf在串口输出Debug调试

[复制链接]

3

主题

7

帖子

0

精华

新手上路

积分
39
金钱
39
注册时间
2015-8-14
在线时间
0 小时
发表于 2015-8-14 10:25:22 | 显示全部楼层 |阅读模式
5金钱

#include "stm32f10x.h"
#include "stdio.h"

void UART1_Configuration(void)
{
USART_InitTypeDef USART_InitStructure;
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
  
  USART_InitStructure.USART_BaudRate = 9600;
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  USART_InitStructure.USART_StopBits = USART_StopBits_2;
  USART_InitStructure.USART_Parity = USART_Parity_Odd;
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

  /* Configure the USART1 */
  USART_Init(USART1, &USART_InitStructure);

  /* Enable the USART Transmoit interrupt: this interrupt is generated when the 
     USART1 transmit data register is empty */  
  USART_ITConfig(USART1, USART_IT_TXE, ENABLE);

  /* Enable the USART Receive interrupt: this interrupt is generated when the 
     USART1 receive data register is not empty */
  USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);

  /* Enable USART1 */
  USART_Cmd(USART1, ENABLE);

}
int fputc(int ch, FILE *f) 

    USART_SendData(USART1, (u8) ch); 
 
     
    /* Loop until the end of transmission */ 
    while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET) 
    { 
    } 

    return ch; 
}

 
int main(void)
{  

 UART1_Configuration();

printf("nihao");





}
为什么我的这个用MDK中debug调试不显示打印nihao?

最佳答案

查看完整内容[请看2#楼]

谢谢了,已经解决,是I/O口都没有初始化
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

3

主题

7

帖子

0

精华

新手上路

积分
39
金钱
39
注册时间
2015-8-14
在线时间
0 小时
 楼主| 发表于 2015-8-14 10:25:23 | 显示全部楼层
谢谢了,已经解决,是I/O口都没有初始化
回复

使用道具 举报

14

主题

1592

帖子

0

精华

资深版主

Rank: 8Rank: 8

积分
2622
金钱
2622
注册时间
2014-7-17
在线时间
350 小时
发表于 2015-8-14 10:36:17 | 显示全部楼层
大哥你main函数里面没有while(1)循环啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-2-25 03:27

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表