完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
各位大侠,小弟刚接触到一块STM32207的开发板,在UCOS移植过程中,发现USART1 和USART2 USART3 有些许不同 同样配置方法 1 3 都顺利能进入中断 可惜USART2始终不能进入中断。敢请哪位前辈指点一二。贴代码如下:
IO级与外设级的配置代码 void USART2_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; RCC_AHB1PeriphClockCmd(Open207Z_USART2_TX_GPIO_CLK,ENABLE); RCC_AHB1PeriphClockCmd(Open207Z_USART2_RX_GPIO_CLK,ENABLE); RCC_APB1PeriphClockCmd(Open207Z_USART2_CLK,ENABLE); GPIO_PinAFConfig(Open207Z_USART2_TX_GPIO_PORT, Open207Z_USART2_TX_SOURCE, Open207Z_USART2_TX_AF); GPIO_PinAFConfig(Open207Z_USART2_RX_GPIO_PORT, Open207Z_USART2_RX_SOURCE, Open207Z_USART2_RX_AF); GPIO_InitStructure.GPIO_Pin = Open207Z_USART2_TX_PIN; 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(Open207Z_USART2_TX_GPIO_PORT, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = Open207Z_USART2_RX_PIN; GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(Open207Z_USART2_RX_GPIO_PORT, &GPIO_InitStructure); RCC_AHB1PeriphClockCmd(Open207Z_USART2_RTS_GPIO_CLK,ENABLE); RCC_AHB1PeriphClockCmd(Open207Z_USART2_CTS_GPIO_CLK,ENABLE); GPIO_PinAFConfig(Open207Z_USART2_RTS_GPIO_PORT, Open207Z_USART2_RTS_SOURCE, Open207Z_USART2_RTS_AF); GPIO_PinAFConfig(Open207Z_USART2_CTS_GPIO_PORT, Open207Z_USART2_CTS_SOURCE, Open207Z_USART2_CTS_AF); GPIO_InitStructure.GPIO_Pin = Open207Z_USART2_RTS_PIN; 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(Open207Z_USART2_RTS_GPIO_PORT, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = Open207Z_USART2_CTS_PIN; GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(Open207Z_USART2_CTS_GPIO_PORT, &GPIO_InitStructure); USART_ITConfig(Open207Z_USART2,USART_IT_RXNE,ENABLE); USART_ClearITPendingBit(USART2,USART_IT_RXNE); USART_Cmd(Open207Z_USART2, ENABLE); } void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;//一共三个中断 选择1组 分别为 00 01 02 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } 中断服务子程序 void USART2_IRQHandler(void) { CPU_SR cpu_sr; CPU_CRITICAL_ENTER(); /* Tell uC/OS-II that we are starting an ISR */ OSIntNesting++; CPU_CRITICAL_EXIT(); if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) { /* Read one byte from the receive data register */ USART_ClearITPendingBit(USART2, USART_IT_RXNE); /* Clear the USART Receive interrupt */ USART_SendData(Open207Z_USART2, (uint8_t)USART_ReceiveData(Open207Z_USART2)); } OSIntExit(); } 其他两个除去标号不同,配置方法都是一样的,目前中断都能顺利产生,而且还有一点就是1 3口都能ISP下载程序,偏偏2不行 请问为什么呢? |
|
相关推荐
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
787 浏览 0 评论
飞凌嵌入式ElfBoard ELF 1板卡-mfgtools烧录流程介绍之烧写所需镜像
888 浏览 0 评论
飞凌嵌入式ElfBoard ELF 1板卡-mfgtools烧录流程之烧写方法
608 浏览 0 评论
飞凌嵌入式ElfBoard ELF 1板卡-内核编译之初次编译
905 浏览 0 评论
飞凌嵌入式ElfBoard ELF 1板卡-内核源代码的目录结构和文件说明
821 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 21:10 , Processed in 0.485398 second(s), Total 72, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号