完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
用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串口的例程 |
|
相关推荐
8个回答
|
|
|
IO配置问题,TX为输出,RX为输入.
|
|
|
|
|
|
只为领金币。。。
|
|
|
|
|
|
TX配置为输出,RX配置为输入。
|
|
|
|
|
|
同问,楼主解决了吗?
|
|
|
|
|
|
我最近也遇到類似問題,不知樓主加時間是否解決
|
|
|
|
|
|
楼主解决了吗?我也是这个问题
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
STM32F405驱动DS1302时钟模块,输出时间错乱该怎么排查?
2797 浏览 2 评论
stm32f405rgt6驱动DS1302ZN出现时间错乱问题
2403 浏览 1 评论
stm32用fsmc读取ad7606采集数据,数据不变,只有开发版复位才更新数据
2276 浏览 0 评论
2388 浏览 1 评论
1637 浏览 1 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 00:47 , Processed in 1.110816 second(s), Total 56, Slave 49 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
418