串口中断服务函数void USART1_IQRHandler(void)
{
if(USART_Ge
tiTStatus(USART1,USART_IT_RXNE)!=RESET)
{
GPIO_SetBits(GPIOA,GPIO_Pin_0);
USART_ClearITPendingBit(USART1,USART_IT_RXNE);
}
}
主函数
int main(void)
{
NVIC_Configuration();
USART1_Config();
while(1);
}
配值函数
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_Init(USART1, &USART_InitStructure); //填充完结构体,调用库函数USART_Init()向寄存器写入配置参数。
USART_ITConfig(USART1,USART_IT_RXNE,ENABLE);//开接收中断
USART_Cmd(USART1, ENABLE);
为什么我一开串口调试工具灯就灭了,我还没发数据灯就没了,而且一打开串口灯又亮了pa1.0 不知道咋回事
一周热门 更多>