我USART1配置好了能通信,但是按同样方式配置USART2就不能通信?不知道是什么问题。还有个问题如果串口USART1占用了 I2C1是不是就不能用了 引文都在PA9 和PA10上。 代码下面: void USART1_uConfiguration(void) { GPIO_InitTypeDef GPIO_uInitStructure; USART_InitTypeDef USART_uInitStructure; // USART1_TX -> PA9 // USART1_RX -> PA10 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE); GPIO_PinAFConfig(GPIOA,GPIO_PinSource2,GPIO_AF_1); GPIO_PinAFConfig(GPIOA,GPIO_PinSource3,GPIO_AF_1); GPIO_uInitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3; GPIO_uInitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_uInitStructure.GPIO_OType = GPIO_OType_PP; GPIO_uInitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_uInitStructure.GPIO_Speed = GPIO_Speed_50MHz; // 50M GPIO_Init(GPIOA,&GPIO_uInitStructure); USART_uInitStructure.USART_BaudRate = 115200; USART_uInitStructure.USART_Parity = USART_Parity_No; USART_uInitStructure.USART_StopBits = USART_StopBits_1; USART_uInitStructure.USART_WordLength = USART_WordLength_8b; USART_uInitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_uInitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_Init(USART2,&USART_uInitStructure); USART_ITConfig(USART2,USART_IT_RXNE,ENABLE); USART_Cmd(USART2,ENABLE); } void NVIC_uConfiguration(void) { NVIC_InitTypeDef NVIC_InitStructure; NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } void USART1_RecTask(void) { INT8U ubTemp = 0; if(USART_GetITStatus(USART2,USART_IT_RXNE) != RESET) { ubTemp = USART_ReceiveData(USART2); USART_SendData(USART2,ubTemp); while(USART_GetFlagStatus(USART2,USART_FLAG_TC) != SET); } } |
【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定时慢很多问题?
评分
查看全部评分
评分
查看全部评分
STM32F030F4的确不存在USART2.