| 
 
| 本帖最后由 zhxingyu 于 2018-11-6 08:46 编辑 
 static void RCC_Configuration(void)
 {
 /* Enable GPIO clock */
 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA|RCC_AHBPeriph_GPIOB|RCC_AHBPeriph_GPIOC|RCC_AHBPeriph_GPIOD|RCC_AHBPeriph_GPIOF, ENABLE);
 
 /* Enable 8xUSARTs Clock */
 RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2|RCC_APB1Periph_USART3|RCC_APB1Periph_USART4|RCC_APB1Periph_USART5, ENABLE);
 
 RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6|RCC_APB2Periph_USART7|RCC_APB2Periph_USART8|RCC_APB2Periph_USART1, ENABLE);
 }
 static void NVIC_Configuration(void)
 {
 NVIC_InitTypeDef NVIC_InitStructure;
 
 /* USART1 IRQ Channel configuration */
 NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
 NVIC_InitStructure.NVIC_IRQChannelPriority = 0x01;
 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
 NVIC_Init(&NVIC_InitStructure);
 
 /* USART2 IRQ Channel configuration */
 NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
 NVIC_InitStructure.NVIC_IRQChannelPriority = 0x01;
 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
 NVIC_Init(&NVIC_InitStructure);
 
 /* USART3_8 IRQ Channel configuration */
 NVIC_InitStructure.NVIC_IRQChannel = USART3_8_IRQn;
 NVIC_InitStructure.NVIC_IRQChannelPriority = 0x01;
 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
 NVIC_Init(&NVIC_InitStructure);
 }
 /* USART3 Pins configuration  ***********************************************/
 /* Connect pin to Periph */
 GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_4);
 GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_4);
 
 /* Configure pins as AF pushpull */
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
 GPIO_Init(GPIOB, &GPIO_InitStructure);
 
 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_Init(USART3, &USART_InitStructure);
 
 /* Enable 8xUSARTs Receive interrupts */
 USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
 
 /* Enable the 8xUSARTs */
 USART_Cmd(USART3, ENABLE);
 
 void USART3_8_IRQHandler(void)
 {
 if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)
 {
 dumm = USART_ReceiveData(USART3);
 // if(Usart_RxSetp(UsartIndex,dumm) == 0)return;
 Usart_RxSetp(UsartIndex,dumm);
 }
 }
 请帮忙看看USART3无法进入接收中断,能正常发送。当有数据时即进入死循环函数:
 void HardFault_Handler(void)
 {
 /* Go to infinite loop when Hard Fault exception occurs */
 while (1)
 {
 }
 }
 | 
 |