//下面是部分配置 USART_InitTypeDef USART_InitStructure; USART_InitStructure.USART_BaudRate = 1200; USART_InitStructure.USART_WordLength = USART_WordLength_9b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_Even ; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART3, &USART_InitStructure); USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); USART_Cmd(USART3, ENABLE); /* Configure the USART3 IrDA mode */ USART_IrDAConfig(USART3, USART_IrDAMode_Normal); USART_IrDACmd(USART3,ENABLE);// |
RE:stm32的irda功能,怎么输不出1200bps,38.4k的红外载波信号(72mhz系统主频)
RE:stm32的irda功能,怎么输不出1200bps,38.4k的红外载波信号(72mhz系统主频)
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);
}
回复:stm32的irda功能,怎么输不出1200bps,38.4k的红外载波信号(72mhz系统主频)