STM32F030R8, PA2,3作为UART2,能发送,不能中断接收数据。 UART1是正常的。请高手看看哪里有问题? 中断函数在.s 中做了处理。 void UART1_GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_AHBPeriphClockCmd( RCC_AHBPeriph_GPIOA, ENABLE); GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_1); GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_1); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9|GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); } void USART1_Configuration(void) { USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPriority = 2; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE ); 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(USART1, &USART_InitStructure); USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); USART_Cmd(USART1, ENABLE); } void USART1_IRQHandler(void) { uint8_t r; if((USART1->ISR & USART_ISR_TC) == USART_ISR_TC) { USART1->ICR |= USART_ICR_TCCF;/* clear transfer complete flag */ } else if((USART1->ISR & USART_ISR_RXNE) == USART_ISR_RXNE) { r = USART1->RDR;/* receive data, clear flag */ USART_SendData(USART1, r); } else { NVIC_DisableIRQ(USART1_IRQn);/* Disable USART1_IRQn */ } } extern void UART1_send_byte(uint8_t byte) { while(!((USART1->ISR)&(1ISR & USART_ISR_TC) == USART_ISR_TC) { USART2->ICR |= USART_ICR_TCCF;/* clear transfer complete flag */ } else if((USART2->ISR & USART_ISR_RXNE) == USART_ISR_RXNE) { r = USART2->RDR;/* receive data, clear flag */ USART_SendData(USART2, r); } else { NVIC_DisableIRQ(USART2_IRQn);/* Disable USART1_IRQn */ } } extern void UART2_send_byte(uint8_t byte) { while(!((USART2->ISR)&(1 |
【STM32F0开发日志/评测/笔记】+互补PWM波的产生
STM32F030 PB14和PB15无法输出PWM求助
【STM32F030探索套件】序列之五 外部中断
【STM32F0开发日志---二】+ucosii.2.92移植在STM32F030
上传个STM32F0+5110+内部温度传感器的菜鸟实例
【STM32F030探索套件使用问题】STM32F030 SPI方式驱动ST7565LCD失败
求一份STM32F051 I2C驱动LCD 12864的例程
STM32F0 M0 向结构体赋值进入HardFault异常
STM32F0 ADC-DMA方式采集2路数据时出现问题
STM32F030C8T6,TIM16定时慢很多问题?
回复:STM32F030R8 UART2中断不能接受数据