OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 1602|回复: 2

开启单个外部中断线,其他输入io也可以触发该外部中断

[复制链接]

1

主题

4

帖子

0

精华

初级会员

Rank: 2

积分
64
金钱
64
注册时间
2017-6-2
在线时间
8 小时
发表于 2018-12-12 09:48:13 | 显示全部楼层 |阅读模式
10金钱
使用stm32f1rct6,开启外部中断线3(PC3),其他输入引脚的下降沿也会触发外部中断3,求大神搭救


GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
  GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC,ENABLE);



  //Port A IO config
  GPIO_DeInit(GPIOA);
GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
BEEP_OFF;

GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_11 | GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IPU;
GPIO_Init(GPIOA, &GPIO_InitStructure);

//Port B IO config
  GPIO_DeInit(GPIOB);
GPIO_InitStructure.GPIO_Pin   =  GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_10
                 | GPIO_Pin_11 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15  ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOB, &GPIO_InitStructure);

// GPIO_SetBits(GPIOB, GPIO_Pin_5);
//Port C IO config
  GPIO_DeInit(GPIOC);
GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_0 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 |
                 GPIO_Pin_0 | GPIO_Pin_11;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_1  | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5
                 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IPU;
GPIO_Init(GPIOC, &GPIO_InitStructure);

EXTI->PR    = 0x1000;
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC,GPIO_PinSource3 );
EXTI->RTSR  = 0;
EXTI->FTSR  = 0x04;                //0X19fe;
EXTI->SWIER = 0;         //0x10ff
//EXTI_Init
EXTI->PR    = 0x04;

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn;   //ͨµÀÉèÖÃΪÍⲿÖжÏ3
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;   //ÖжÏÕ¼Ïȵȼ¶0
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;          //ÖжÏÏìÓ¦ÓÅÏȼ¶0
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;             //´ò¿ªÖжÏ
  NVIC_Init(&NVIC_InitStructure);

EXTI->IMR   = 0X04;

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

57

主题

1680

帖子

3

精华

资深版主

Rank: 8Rank: 8

积分
4307
金钱
4307
注册时间
2018-6-30
在线时间
808 小时
发表于 2018-12-12 17:51:52 | 显示全部楼层
你用正点原子外部中断的源程序试下
业精于勤荒于嬉;行成于思毁于随!
回复

使用道具 举报

31

主题

1955

帖子

3

精华

论坛元老

Rank: 8Rank: 8

积分
4523
金钱
4523
注册时间
2018-5-11
在线时间
947 小时
发表于 2018-12-12 18:41:32 | 显示全部楼层
EXTI->FTSR  = 0x04;               
EXTI->PR    = 0x04;
PC3的话应该是0x08吧?
我的开源链接 https://github.com/ShuifaHe/STM32.git  请关注,点赞支持哦。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-22 13:19

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表