学前班
最后登录1970-1-1
在线时间 小时
注册时间2015-7-29
|
买了野火的板那么久第一次发帖,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);
}
|
|