在线时间0 小时
UID261321
ST金币0
蝴蝶豆0
注册时间2011-1-28
新手上路
- 最后登录
- 1970-1-1
|
发表于 2011-8-12 10:13:29
|
显示全部楼层
a0a.1 0b0c
RE:stm32的irda功能,怎么输不出1200bps,38.4k的红外载波信号(72mhz系统主频)
#include "IrDA.h"
void init_irda(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
/* Enable GPIO clock */
RCC_APB2PeriphClockCmd(USARTy_GPIO_CLK | RCC_APB2Periph_AFIO, ENABLE);
/* Enable USARTy clocks */
RCC_APB1PeriphClockCmd(USARTy_CLK, ENABLE);
/* Enable the USART2 Pins Software Remapping */
//GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
/* Configure USARTy Tx as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = USARTy_TxPin;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(USARTy_GPIO, &GPIO_InitStructure);
/* Configure USARTy Rx as input floating */
GPIO_InitStructure.GPIO_Pin = USARTy_RxPin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(USARTy_GPIO, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = 1200;
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;
/* Configure the USARTy */
USART_Init(USARTy, &USART_InitStructure);
/* Enable the USARTy */
USART_Cmd(USARTy, ENABLE);
/* Set the USARTy prescaler */
USART_SetPrescaler(USARTy, 0x1);
/* Configure the USARTy IrDA mode */
USART_IrDAConfig(USARTy, USART_IrDAMode_Normal);
/* Enable the USARTy IrDA mode */
USART_IrDACmd(USARTy, ENABLE);
} |
|