用STM32F401RE NUCLEO串口中断收发,配置函数如下: void UARTConfiguration(void) { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; USART_ClockInitTypeDef USART_ClockInitStruct; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC,ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE); GPIO_PinAFConfig(GPIOA,GPIO_PinSource2,GPIO_AF_USART2); GPIO_PinAFConfig(GPIOA,GPIO_PinSource3,GPIO_AF_USART2); GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3; 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_UP; GPIO_Init(GPIOA,&GPIO_InitStructure); // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; // GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; // GPIO_Init(GPIOA,&GPIO_InitStructure); // USART_DeInit(USART2); // USART_OverSampling8Cmd(USART2,ENABLE); USART_StructInit(&USART_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(USART2, &USART_InitStructure); USART_ClockStructInit(&USART_ClockInitStruct); USART_ClockInit(USART2, &USART_ClockInitStruct); USART_Cmd(USART2, ENABLE); // USART_ClearFlag(USART2,USART_FLAG_TC); USART_ITConfig(USART2,USART_IT_RXNE,ENABLE); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd =ENABLE; NVIC_Init(&NVIC_InitStructure); } 串口一直不能进中断,而且如果在主函数中发数据,串口调试助手中也没有数据,求大神指点一下,或者直接给我一个STM32F401RE NUCLEO串口的例程 |
盘古UE-STM32F407工控板原理图
STM32F407 定时器触发DMA 求助大神
【MCU实战经验】基于STM32F407的音频播放器设计
【STM32F429心得\疑问】+STM32F4之FSMC和FMC
STM32F429读取IO口传输的数据速率
STM32F407ZGT6 手摸芯片背部重启
STM32F4 SPI 动作时,软件片选信号被拉高,IO口程序逻辑失控
读取STM32F407内部温度传感器值错误
STM32F429多路内部ADC独立采集的办法
STM32F407 的1588问题(已解决)
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;这里配置为OUT??
请问您解决了吗
请问您解决了吗
STM32F401RE NUCLEO的串口2和STINK接在了一起,硬件问题,可以把那个电阻焊下来,或者那串口助手的端口选择为STM32的那个端口。