开了中断可是不知道怎么回事,老进入ISR,我的设置过程如下,请高手帮忙看下问题出在哪里 当执行到下面时,老是进入USART1_IRQHandler(); USART_ITConfig(USART1,USART_IT_TXE,ENABLE);
void NVIC_Config(void) {
NVIC_InitTypeDef NVIC_USART1_S;
NVIC_DeInit(); NVIC_SCBDeInit();
// NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); // NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
NVIC_ClearIRQChannelPendingBit(USART1_IRQChannel);
NVIC_USART1_S.NVIC_IRQChannel= USART1_IRQChannel; NVIC_USART1_S.NVIC_IRQChannelPreemptionPriority =3; NVIC_USART1_S.NVIC_IRQChannelSubPriority=5; NVIC_USART1_S.NVIC_IRQChannelCmd=ENABLE; NVIC_Init(&NVIC_USART1_S);
}
void SetupUART (void) {
GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; /* Enable GPIOA clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
/* Configure USART1 Rx (PA10) as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USART1 Tx (PA9) as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure);
/* USART1 configured as follow: - BaudRate = 115200 baud - Word Length = 8 Bits - One Stop Bit - No parity - Hardware flow control disabled (RTS and CTS signals) - Receive and transmit enabled - USART Clock disabled - USART CPOL: Clock is active low - USART CPHA: Data is captured on the middle - USART LastBit: The clock pulse of the last data bit is not output to the SCLK pin */ 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(USART1, &USART_InitStructure);
//CONFIG USART INTERRPUT //add 2008 8-11 zsf USART_ITConfig(USART1,USART_IT_RXNE,ENABLE); USART_ITConfig(USART1,USART_IT_TXE,ENABLE);
// USART1-> CR1|=0x00a0;
USART_Cmd(USART1, ENABLE); /* Enable USART1 */
}
void USART1_IRQHandler(void) { // GPIOB->ODR = (GPIOB->ODR & 0xFFFF00FF) | (LED1 << 8);
/* if(USART_GetITStatus(USART1, USART_FLAG_RXNE)==SET) { USART_ITConfig(USART3, USART_IT_RXNE, DISABLE); GPIOB->ODR = (GPIOB->ODR & 0xFFFF00FF) | (2 << 8); Read_Byte=USART_ReceiveData(USART1); }
if(USART_GetITStatus(USART1, USART_IT_TXE)==SET) { // USART_ClearITPendingBit(USART1,USART_IT_TXE); GPIOB->ODR = (GPIOB->ODR & 0xFFFF00FF) | (1 << 8); // USART1->DR=0x55; // USART_SendData(USART1,100); }
*/ /* If a Frame error is signaled by the card */ if(USART_GetITStatus(USART1, USART_IT_FE) != RESET) { USART_ReceiveData(USART1);
/* Resend the byte that failed to be received (by the Smartcard) correctly */ // SC_ParityErrorHandler(); } /* If the USART3 detects a parity error */ if(USART_GetITStatus(USART1, USART_IT_PE) != RESET) { /* Enable USART3 RXNE Interrupt (until receiving the corrupted byte) */ USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); /* Flush the USART3 DR register */ USART_ReceiveData(USART1); } if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) { /* Disable USART3 RXNE Interrupt */ USART_ITConfig(USART1, USART_IT_RXNE, DISABLE); USART_ReceiveData(USART1); } /* If a Overrun error is signaled by the card */ if(USART_GetITStatus(USART1, USART_IT_ORE) != RESET) { USART_ReceiveData(USART1); } /* If a Noise error is signaled by the card */ if(USART_GetITStatus(USART1, USART_IT_NE) != RESET) { USART_ReceiveData(USART1); } }
|