加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

STM8 外部中断配置方法

(2013-12-28 10:18:40)
标签:

stm8

外部中断

配置

分类: STM8技术博文

1:引用STM8 的中断库

  #include "stm8s_exti.h"

2:配置外部中断的触发管脚

GPIO_Init(LEDS_PORT,MB,GPIO_MODE_IN_FL_IT );

或者

GPIO_Init(LEDS_PORT,MB,GPIO_MODE_IN_PU_IT );

3:初始化中断

EXTI_DeInit();

EXTI_SetTLISensitivity(EXTI_TLISENSITIVITY_RISE_ONLY);//下降沿触发中断
EXTI_SetExtIntSensitivity((EXTI_PORT_GPIOD),EXTI_SENSITIVITY_RISE_ONLY);

 

4:中断服务子程序的配置

(1)外部定义中断服务子程序

@far @interrupt void EXTI3 (void)

{
  disableInterrupts();
  counter ();
  enableInterrupts();
}

(2)声明外部中断子程序

extern void EXTI3 ();

(3)配置外部中断子程序向量表

struct interrupt_vector const _vectab[] = {
 {0x82, (interrupt_handler_t)_stext},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, EXTI3              },
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, TIM2_UPD_OVF_TRG_IRQHandler },
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, UART_RI            },
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
 {0x82, NonHandledInterrupt},
};

注:在配置中断实以上三部缺一不可

 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有