void USART3_Send_Byte(unsigned char ucSend_Data)
{
USART_SendData(USART3, ucSend_Data);
while(USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET);
}
一直在 while(USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET);死循环,不能进串口的中断。
中断这样配置对不?
/************************************************************ 函数名: NVIC_Config** 功能描述: 中断分组及优先级配置** 输入参数: 无** 输出参数: 无***********************************************************/void NVIC_Config(void){ NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); /*定时器3中断 */ NVIC_InitStructure.NVIC_IRQChannel =
tiM1_CC_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn; //通道设置为串口1中断(故后面应选择在“void USART1_IRQHandler(void)”开中断) NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //中断占先等级0 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //中断响应优先级0 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //打开中断 NVIC_Init(&NVIC_InitStructure);}
USART_SendData(USART3, c);
先判断然后再发送
一周热门 更多>