使用USART1发送,USART2接收,USART3发送和接收,另外使用PE2作为外部中断线。 在NVIC_Configuration()中当注释钓USART3的设置时,程序运行都正常。但是不注释的时候,USART1的发送就没有了,很奇怪,哪个高人给分析分析。 void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); //USART1 NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;//ÉèÖÃIRQͨµÀ NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;//ÉèÖÃÏÈÕ¼ÓÅÏȼ¶ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;//ÉèÖôÓÓÅÏȼ¶ NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//ʹÄÜ»òʧÄÜIRQͨµÀ NVIC_Init(&NVIC_InitStructure); //USART2 NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); //USART3 /* NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;//ÉèÖÃIRQͨµÀ NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;//ÉèÖÃÏÈÕ¼ÓÅÏȼ¶ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;//ÉèÖôÓÓÅÏȼ¶ NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//ʹÄÜ»òʧÄÜIRQͨµÀ NVIC_Init(&NVIC_InitStructure);*/ //Int2PS NVIC_InitStructure.NVIC_IRQChannel = EXTI2_IRQn;//ÉèÖÃIRQͨµÀ NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;//ÉèÖÃÏÈÕ¼ÓÅÏȼ¶ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;//ÉèÖôÓÓÅÏȼ¶ NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//ʹÄÜ»òʧÄÜIRQͨµÀ NVIC_Init(&NVIC_InitStructure); } |
你添加处理代码,看看能不能进入中断。
如果不行,试试提升USART3的中断优先级。
如果还是不行,试试注释串口1和2的代码,
先试串口3,看正不正常。
正常了,再还原测试。
还有,
建议初始化串口后,用 USART_GetITStatus 函数,
把 发送完成标志 USART_FLAG_TC 清一下。
评分
查看全部评分
评分
查看全部评分