在用USART3通讯时,不断发送数据时就死机了。当停止IAR编译器,出现"CPU not halted",哪位高手遇到这种情况,可能哪些原因引起的, 初始化: 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_InitStructure.USART_Clock = USART_Clock_Disable; USART_InitStructure.USART_CPOL = USART_CPOL_Low; USART_InitStructure.USART_CPHA = USART_CPHA_2Edge; USART_InitStructure.USART_LastBit = USART_LastBit_Disable;
USART_Init(USART3, &USART_InitStructure);
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); USART_ITConfig(USART3, USART_IT_TXE, ENABLE); USART_Cmd(USART1, ENABLE);
中断函数: void USART3_IRQHandler(void) { BYTE bTmp; if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) { /* Clear the USART3 Receive interrupt */ USART_ClearITPendingBit(USART3, USART_IT_RXNE);
bTmp = (USART_ReceiveData(USART3) & 0x7F);; }
if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET) { /* Clear the USART3 transmit interrupt */ USART_ClearITPendingBit(USART3, USART_IT_TXE); if(fgUartTxBufOut(&bTmp) == TRUE ) { USART_SendData(USART3, bTmp); } else { USART_ITConfig(USART3, USART_IT_TXE, DISABLE); } } } 刚开始通讯都正常,一直有数据通讯时,一会儿就死机了。 |