Atmel Studio-SAM单片机开发 ---EXTINT
来源:互联网 发布:中国网络资讯台无锡市 编辑:程序博客网 时间:2024/05/15 05:15
我自己学习ATMEL ARM也有两个星期了,自己规划了尽量以后能保持一个星期写一篇关于ATMEL ARM单片机的学习或者应用博文。大家的阅读与交流是我最大的动力。
今天我们一起来学习EXTINT,在学习这节内容是可以查看数据手册看到SAMD21是不支持外部中断的,只支持事件触发。
关于中断与事件,下面有比较详细的解释:
好,开始本节的编程:
1:新建工程(参考第一节 —新建工程),直到下面的界面
2:向导界面 Project项选择本工程,并添加本例程需要的ASF模块
3:添加以下测试代码
#include <asf.h>void Board_init(void);void configure_extint_channel(void);void configure_extint_callbacks(void);void extint_detection_callback(void);void Board_init(void){ struct port_config pin_conf; port_get_config_defaults(&pin_conf); /* Configure LEDs as outputs, turn them off */ pin_conf.direction = PORT_PIN_DIR_OUTPUT; port_pin_set_config(PIN_PA00, &pin_conf); port_pin_set_output_level(PIN_PA00, false); /* Set buttons as inputs */ pin_conf.direction = PORT_PIN_DIR_INPUT; pin_conf.input_pull = PORT_PIN_PULL_UP; port_pin_set_config(PIN_PA15, &pin_conf);}//! [setup]void configure_extint_channel(void){ //! [setup_1] struct extint_chan_conf config_extint_chan; //! [setup_1] //! [setup_2] extint_chan_get_config_defaults(&config_extint_chan); //! [setup_2] //! [setup_3] config_extint_chan.gpio_pin = PIN_PA15A_EIC_EXTINT15; config_extint_chan.gpio_pin_mux = MUX_PA15A_EIC_EXTINT15; config_extint_chan.gpio_pin_pull = EXTINT_PULL_UP; config_extint_chan.detection_criteria = EXTINT_DETECT_BOTH; //! [setup_3] //! [setup_4] extint_chan_set_config(15, &config_extint_chan); //! [setup_4]}void configure_extint_callbacks(void){ //! [setup_5] extint_register_callback(extint_detection_callback, 15, EXTINT_CALLBACK_TYPE_DETECT); //! [setup_5] //! [setup_6] extint_chan_enable_callback(15, EXTINT_CALLBACK_TYPE_DETECT); //! [setup_6]}//! [setup_7]void extint_detection_callback(void){ bool pin_state = port_pin_get_input_level(PIN_PA15); port_pin_set_output_level(PIN_PA00, pin_state);}int main (void){ system_init(); Board_init(); configure_extint_channel(); configure_extint_callbacks(); system_interrupt_enable_global(); /* Insert application code here, after the board has been initialized. */ while (true) { }}
4:编译下载即可以测试效果,想看到不同的测试效果可以改变
void configure_extint_channel(void)函数
config_extint_chan.detection_criteria = EXTINT_DETECT_BOTH;这个项的值。
此值有以下可选:
/**
* \brief External interrupt edge detection configuration enum.
*
* Enum for the possible signal edge detection modes of the External
* Interrupt Controller module.
*/
enum extint_detect {
/** No edge detection. Not allowed as a NMI detection mode on some
* devices. */
EXTINT_DETECT_NONE = 0,
/* Detect rising signal edges /
EXTINT_DETECT_RISING = 1,
/* Detect falling signal edges /
EXTINT_DETECT_FALLING = 2,
/* Detect both signal edges /
EXTINT_DETECT_BOTH = 3,
/* Detect high signal levels /
EXTINT_DETECT_HIGH = 4,
/* Detect low signal levels /
EXTINT_DETECT_LOW = 5,
};
本次文章到此结束,有任何异议或者疑问欢迎留言讨论!!!
- Atmel Studio-SAM单片机开发 ---EXTINT
- Atmel Studio-SAM单片机开发 ---新建工程
- Atmel Studio-SAM单片机开发 ---PIO
- Atmel单片机应用技巧
- Atmel单片机应用技巧
- ATmega128a AVR开发工具:atmel studio 6.0下Makefile编写
- AVRWARE++开发笔记8:Atmel Studio去除拼写检查
- AVRWARE++开发笔记9:应用Atmel Studio学习C语言
- 使用Atmel Studio 7编程Arduino Due开发板
- 使用Atmel Studio编程Arduino Uno开发板
- Atmel studio注意事项
- Atmel单片机并口下载线制作
- Atmel Studio 6.0 SP2 2.4 Gb.txt
- atprogram.exe : Atmel Studio Command Line Interface
- Atmel三款带10位ADC的AVR单片机
- Atmel三款带10位ADC的AVR单片机
- atmel sama5d3x_xplained a5开发板刷linux
- sam
- 什么是BI工程师
- Codeforces Round #426 (Div. 2)-B. The Festive Evening
- scala使用reduce和fold方法遍历集合的所有元素
- const与#define
- linux下源码包安装apache
- Atmel Studio-SAM单片机开发 ---EXTINT
- 关于RecyclerView列表点击事件ripple效果失效的问题
- 深搜 加奇偶剪枝
- jQuery获取格式化当前时间
- Kotlin Reference (三) Coding Conventions
- 雷军给程序员的五点建议--如何成为编程高手并以此创业
- [Muduo网络库源码分析] (5) base/FileUtil.cc_h_文件操作
- Scala定义函数的5种方式
- 有关数组的基础递归