最近在做STM32F3x系列的串口实验,使用中断一直无法接受发送数据,不知道哪里错了,请大神们指教。 程序: void My_USART1_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);//使能USART1时钟 GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_7); GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_7); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 ; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOA, &GPIO_InitStructure); USART_InitStructure.USART_BaudRate=115200; USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode=USART_Mode_Rx|USART_Mode_Tx; USART_InitStructure.USART_Parity=USART_Parity_No; USART_InitStructure.USART_StopBits=USART_StopBits_1; USART_InitStructure.USART_WordLength=USART_WordLength_8b; USART_Init(USART1,&USART_InitStructure); USART_Cmd(USART1 ,ENABLE); USART_ITConfig(USART1,USART_IT_RXNE,ENABLE); USART_ITConfig(USART1,USART_IT_TXE,ENABLE); NVIC_InitStructure.NVIC_IRQChannel=USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0; NVIC_InitStructure.NVIC_IRQChannelSubPriority=1; NVIC_Init(&NVIC_InitStructure); } void USART1_IRQHandler(void) { uint16_t res; if(USART_GetITStatus(USART1,USART_IT_RXNE)==SET){ res=USART_ReceiveData(USART1); USART_SendData(USART1,res); } } int main(void) { My_USART1_Init(); while(1){}; } 另本人不明白,USART1_IRQHandler()函数是自动被调用吗?main()函数里没有这个函数? |
STM32F3 硬件I2C 驱动OLED 求助!!
STM32F303使用定时器触发双ADC常规同步采样模式
哪位大哥传下STM32F334 Nucleo的工程模板给我下
STM32F334 不能串口下载
关于STM32F334的HRTIM分辨率问题
STM32F303+LCD1602程序问题,不只为什么点不亮?
STM32F334的ADC使用问题
STM32F334 HRTIM形成移相全桥波形问题
有用过STM32F373VC的板子么 iic 例程不好使
STM32F3 ADC外部触发采样达不到7.2MSPS
系统怎么知道进入这个函数呢?是根据这个名字来识别的吗?其他名字是不是就不行了。
另我运行后,进入了busfault_handle,然后就卡住了,请问是为什么呢?
看启动文件