打印

STM32F101RB,进不了中断?

[复制链接]
1760|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
gene719|  楼主 | 2010-5-29 19:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
大家好,小弟刚接触stm32;最近刚做一板子,其中一功能就是通过串口发送数据,然后接收数据;发送数据没问题,但就是进不了接收中断(通过串口助手监视,有接收数据);最后又试了一下按键(连外部中断14 和15),测试还是进不了中断! 搞了一天,没有结果;希望大侠们指点,帮我“进入中断”;先谢了。。。。

我的中断配置
void NVIC_Configuration(void)
{
  NVIC_InitTypeDef NVIC_InitStructure;
  //NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x2000);
  // 配置优先级分组,无抢占式优先级  
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
  
  // 配置USART1中断优先级
  NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  // 配置USART2中断优先级
  NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  // 配置USART3中断优先级
  NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  // 2010-05-26, zhangxingjuan
  NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;  //中断通道
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;    //次优先级
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;       //通道中断使能
  NVIC_Init(&NVIC_InitStructure);                       //初始化中断
}


串口配置
void USART123_Init(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;      // GPIO 初始化结构体
USART_InitTypeDef USART_InitStructure;      // USART 初始化结构体
                     
//***********Configure USART1 Tx Pin*********
GPIO_InitStructure.GPIO_Pin = GPIO_Tx1PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
//***********Configure USART2 Tx Pin********
    GPIO_InitStructure.GPIO_Pin = GPIO_Tx2PIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
//***********Configure USART3 Tx Pin*********
    GPIO_InitStructure.GPIO_Pin = GPIO_Tx3PIN;
GPIO_Init(GPIOB, &GPIO_InitStructure);
   //***********Configure USART1 Rx Pin*********
    GPIO_InitStructure.GPIO_Pin = GPIO_Rx1PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
//***********Configure USART2 Rx Pin*********
    GPIO_InitStructure.GPIO_Pin = GPIO_Rx2PIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
//***********Configure USART3 Rx Pin*********
    GPIO_InitStructure.GPIO_Pin = GPIO_Rx3PIN;
GPIO_Init(GPIOB, &GPIO_InitStructure);  
    //********USART1 configure para*********
USART_InitStructure.USART_BaudRate = 2400;
USART_InitStructure.USART_WordLength = USART_WordLength_9b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_Even;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
    USART_Init(USART1,&USART_InitStructure);
  
/********USART2 configure para*********/
    USART_Init(USART2,&USART_InitStructure);  

/********USART3 configure para**********/
    USART_Init(USART3,&USART_InitStructure);
// 使能USART1、2、3的接收中断
    USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
// 使能USART1、2、3  
USART_Cmd(USART1, ENABLE);
USART_Cmd(USART2, ENABLE);
USART_Cmd(USART3, ENABLE);         
}
/**
  * @描述:配置系统中断
  * @入口参数: 无
  */
  
void NVIC_Configuration(void)
{
  NVIC_InitTypeDef NVIC_InitStructure;
  //NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x2000);
  // 配置优先级分组,无抢占式优先级  
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
  
  // 配置USART1中断优先级
  NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  // 配置USART2中断优先级
  NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  // 配置USART3中断优先级
  NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  // 2010-05-26, zhangxingjuan
  NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;  //中断通道
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;    //次优先级
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;       //通道中断使能
  NVIC_Init(&NVIC_InitStructure);                       //初始化中断
}


是不是还缺少设置什么?
加一天班,现在是彻底的晕了~~~~

相关帖子

沙发
gene719|  楼主 | 2010-5-29 21:46 | 只看该作者
补充:我用的是MDK4.0+J-Link调试方法

使用特权

评论回复
板凳
gene719|  楼主 | 2010-5-30 19:44 | 只看该作者
:sleepy:问题已解决,硬件问题

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

3

帖子

1

粉丝