STM8 外部中断配置方法

来源:本站
导读:目前正在解读《STM8 外部中断配置方法》的相关信息,《STM8 外部中断配置方法》是由用户自行发布的知识型内容!下面请观看由(电工技术网 - www.9ddd.net)用户发布《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 )...

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},

};

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

提醒:《STM8 外部中断配置方法》最后刷新时间 2024-03-14 01:12:07,本站为公益型个人网站,仅供个人学习和记录信息,不进行任何商业性质的盈利。如果内容、图片资源失效或内容涉及侵权,请反馈至,我们会及时处理。本站只保证内容的可读性,无法保证真实性,《STM8 外部中断配置方法》该内容的真实性请自行鉴别。