OpenEdv-开源电子网

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

初学固件库,历程也参考了很多了,串口就是跑不出来....应该是一个很幼稚的错误...望指点

[复制链接]

4

主题

8

帖子

0

精华

初级会员

Rank: 2

积分
54
金钱
54
注册时间
2013-4-13
在线时间
4 小时
发表于 2013-4-13 10:05:21 | 显示全部楼层 |阅读模式


  void UART1_GPIO_Configuration(void)  
  {
       GPIO_InitTypeDef GPIO_InitStructure;    
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;  
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;   
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;  //
     GPIO_Init(GPIOA, &GPIO_InitStructure);        // Configure USART1_Rx as input floating         
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;    //  
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//    
     GPIO_Init(GPIOA, &GPIO_InitStructure);
   }

void USART_Configuration(void) {  
 USART_InitTypeDef USART_InitStructure;       //
  USART_ClockInitTypeDef  USART_ClockInitStructure;
 USART_ClockInitStructure.USART_Clock = USART_Clock_Enable;//  
 USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low;  
 USART_ClockInitStructure.USART_CPHA = USART_CPHA_2Edge;  
 USART_ClockInitStructure.USART_LastBit = USART_LastBit_Disable;  
 USART_ClockInit(USART1,&USART_ClockInitStructure);
   USART_InitStructure.USART_BaudRate = 9600;   //
   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_Init(USART1, &USART_InitStructure);      //
 USART_Cmd(USART1, ENABLE);//

  }

  int main(void)
 { 
   UART1_GPIO_Configuration();
  USART_Configuration();

  while(1)
 {
      USART_SendData(USART1, 'A'); //
 }
 }
连上电脑就是不行,但是考一些历程的axf是能发的,自己写的就不行....

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

25

主题

683

帖子

0

精华

论坛大神

Rank: 7Rank: 7Rank: 7

积分
1351
金钱
1351
注册时间
2012-4-25
在线时间
195 小时
发表于 2013-4-13 10:18:47 | 显示全部楼层
回复 支持 反对

使用道具 举报

4

主题

8

帖子

0

精华

初级会员

Rank: 2

积分
54
金钱
54
注册时间
2013-4-13
在线时间
4 小时
 楼主| 发表于 2013-4-13 10:29:43 | 显示全部楼层
哦?感谢大神的关注,能具体说一下吗?我初学,再次感谢
回复 支持 反对

使用道具 举报

4

主题

8

帖子

0

精华

初级会员

Rank: 2

积分
54
金钱
54
注册时间
2013-4-13
在线时间
4 小时
 楼主| 发表于 2013-4-13 10:32:37 | 显示全部楼层
行了,问题是没有是能GPIO的时钟(|GPIOA),感谢大神提醒
回复 支持 反对

使用道具 举报

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

本版积分规则



关闭

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

正点原子公众号

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

GMT+8, 2025-7-21 16:10

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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