找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3189|回复: 0
打印 上一主题 下一主题
收起左侧

STM8外部中断配置详解

[复制链接]
跳转到指定楼层
楼主
ID:90014 发表于 2015-9-14 12:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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},
};
注:在配置中断实以上三部缺一不可



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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