本人小白一个,查询发送可以的。现在想通过串口中断来发送。可是调试发现一直触发中断,查询出不来了。上代码
//初始化
void USART_Config(void)
{
GPIO_Init(GPIOC,2,GPIO_Mode_In_PU_No_IT);
GPIO_Init(GPIOC,3,GPIO_Mode_Out_PP_High_Fast);
CLK_PeripheralClockConfig(CLK_Peripheral_USART1, ENABLE);
USART_DeInit(USART1);
USART_Init(USART1,(uint32_t)9600, USART_WordLength_8b, USART_StopBits_1,
USART_Parity_No, (USART_Mode_TypeDef)(USART_Mode_Rx | USART_Mode_Tx));
USART_ITConfig(USART1,(USART_IT_RXNE|USART_IT_TC),ENABLE); //使能发送接收中断
ITC_SetSoftwarePriority(USART1_TX_IRQn, ITC_PriorityLevel_1); //优先级
ITC_SetSoftwarePriority(USART1_RX_IRQn, ITC_PriorityLevel_1);
USART_Cmd(USART1,ENABLE);
}
//发送中断
INTERRUPT_HANDLER(Uart_TX_IRQHandler,27)
{
USART_SendData8(USART1,(unsigned char)TxBuff[cunt]);
USART_ClearFlag(USART1,USART_IT_TC);
USART_ITConfig(USART1,USART_IT_TC,ENABLE);
}
求解答 |