野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11388|回复: 4

串口irda模式要怎么配置怎么使用

[复制链接]
发表于 2015-8-25 12:04:32 | 显示全部楼层 |阅读模式
买了野火的板那么久第一次发帖,stm32f103串口irda到底要怎么配置。。。。。。。。。。。。。下面的配置按官方例程来,连管脚配置都一样,应该没问题 啊,怎么破?难道是调用的时序 问题?              void IRDA_Config(void)
{
                GPIO_InitTypeDef GPIO_InitStructure;
                USART_InitTypeDef USART_InitStructure;
                //USART_ClockInitTypeDef USART_ClockInitStructure;
               
                /* config USART2 clock */
                RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
                RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE);
               
                GPIO_PinRemapConfig(GPIO_PartialRemap_USART3, ENABLE);
                /* USART2 GPIO config */
                /* Configure USART2 Tx (PA.02) as alternate function push-pull */
                GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
                GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
                GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
                GPIO_Init(GPIOC, &GPIO_InitStructure);
       
                /* Configure USART1 Rx (PA.03) as input floating */
                GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
                GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
                GPIO_Init(GPIOC, &GPIO_InitStructure);
                       
                /* USART1 mode config */
                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_ClockInitStructure.USART_Clock = USART_Clock_Disable;
//                 USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low;
//                 USART_ClockInitStructure.USART_CPHA = USART_CPHA_2Edge;
//                 USART_ClockInitStructure.USART_LastBit = USART_LastBit_Disable;
               
                //USART_ClockInit(USART2,&USART_ClockInitStructure);
                USART_Init(USART3, &USART_InitStructure);
                USART_Cmd(USART3, ENABLE);
               
                /* Set the USART2 prescaler */
                USART_SetPrescaler(USART3, 0x1);
                /* Configure the USART2 IrDA mode */
                USART_IrDAConfig(USART3, USART_IrDAMode_Normal);
                /* Enable the USART2 IrDA mode */
                USART_IrDACmd(USART3, ENABLE);
}
回复

使用道具 举报

 楼主| 发表于 2015-8-25 12:05:34 | 显示全部楼层
这必须得破啊
回复 支持 反对

使用道具 举报

发表于 2015-8-26 09:16:21 | 显示全部楼层
还没用过它的irda功能,看你的配置跟普通的串口功能没有区别呀
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-8-28 20:25:02 | 显示全部楼层
flyleaf 发表于 2015-8-26 09:16
还没用过它的irda功能,看你的配置跟普通的串口功能没有区别呀

区别在于最后加了三句
回复 支持 反对

使用道具 举报

发表于 2019-1-23 14:30:31 | 显示全部楼层
flyleaf 发表于 2015-8-26 09:16
还没用过它的irda功能,看你的配置跟普通的串口功能没有区别呀

你好 在霸道板子原理图中看到有红外模块,但是没有找到红外模块的教程和例程?
回复 支持 反对

使用道具 举报

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

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-5-7 01:28 , Processed in 0.028586 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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