中级会员
 
- 积分
- 244
- 金钱
- 244
- 注册时间
- 2011-12-29
- 在线时间
- 1 小时
|
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB1Periph_USART2|RCC_APB2Periph_GPIOA,ENABLE);
/* Configure USART2 Tx (PA.02) as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USART2 Rx (PA.03) as input floating */
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* USART1 configuration ------------------------------------------------------*/
// USART1 configured as follow:
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;
/* Configure the USART2 */
USART_Init(USART2, &USART_InitStructure);
/* Enable the USART Transmoit interrupt: this interrupt is generated when the
USART1 transmit data register is empty */
//USART_ITConfig(USART2, USART_IT_TXE, ENABLE);
/* Enable the USART Receive interrupt: this interrupt is generated when the
USART1 receive data register is not empty */
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
/* Enable USART2 */
USART_Cmd(USART2, ENABLE);
呼叫原子哥
配置有问题么 这样配置后发送数据时发送中断没有触发
|
|