你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

最近在使用STM32F103的芯片做串口和IR解码以及USB方案

[复制链接]
lqh-414236 发布时间:2014-4-2 16:07
   串口的配置
//复用口的打开 
    GPIO_InitTypeDef GPIO_InitStructure;
     RCC_APB2PeriphClockCmd( RCC_APB2Periph_USART1|RCC_APB2Periph_GPIOA | \
     RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|\
     RCC_APB2Periph_GPIOE|RCC_APB2Periph_AFIO, ENABLE);  

 
 //始终配置 
     RCC_APB1PeriphClockCmd( RCC_APB1Periph_USART2|RCC_APB1Periph_USART3|\
     RCC_APB1Periph_UART4,ENABLE); 
//USART1 GPIO配置
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;             
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 
     GPIO_Init(GPIOA, &GPIO_InitStructure);            

     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;            
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;  
     GPIO_Init(GPIOA, &GPIO_InitStructure);


//USART2 GPIO配置
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;             
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; 
     GPIO_Init(GPIOA, &GPIO_InitStructure);  

   
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;             
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;  
     GPIO_Init(GPIOA, &GPIO_InitStructure); 
//串口的配置
     USART_InitTypeDef USART_InitStructure;
     USART_InitStructure.USART_BaudRate = 115200;
     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_Init(USART2, &USART_InitStructure); 
//中断的配置,注意在中断函数里面清除中断标志     USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);       //ʹÄÜÖжÏ
     USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
     USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);       //ʹÄÜÖжÏ
     USART_ITConfig(UART4, USART_IT_RXNE, ENABLE);
    
     USART_Cmd(USART1, ENABLE);     //ʹÄÜÍâÉè
     USART_Cmd(USART2, ENABLE);     //ʹÄÜ
 


收藏 评论0 发布时间:2014-4-2 16:07

举报

0个回答

所属标签

相似分享

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版