标题:
51单片机入门教程源码,猿始部落官方代码正式版,第七课,外部中断。
[打印本页]
作者:
风随心动
时间:
2016-7-9 11:24
标题:
51单片机入门教程源码,猿始部落官方代码正式版,第七课,外部中断。
原理图在第一课中,请自行下载观看。
/*************************猿始部落官方代码********************************/
/*************************************************************************
File name: main.c ; 文件名
Author: shield; 作者
Date: 2015.2.1; 日期
Email: 2842481126@qq.com; 邮箱地址
Description: 外部中断0、1使能LED0、1亮; 功能描述
Version: V1.0.0; 版本号
Hardware&IDE AT89S52单片机&KEIL UVISION4; 软硬件平台
Copyright (C), source code clan Co., Ltd.; 版权
History: 无; 修改记录
**************************************************************************/
#include <reg52.h> //包含底层寄存器定义
#define uchar unsigned char //定义无符号字符型 8位数据 0-127
#define uint unsigned int //定义无符号整形 16位数据 0-65535
sbit LED_RUN = P0^0;
sbit LED_RUN1 = P0^1;
/************************************************************************
Subroutine: ex_interrupt_init; 子程序名称
Description: 外部中断0、1初始化; 子程序功能的描述
Principium: 外部中断0、1相关寄存器配置; 程序设计原理
Calls: 无; 被本子程序调用的子程序清单
Variables: 无; 本子程序中所用到的临时变量
Input: 无; 子程序调用所需要基本参数的说明
Output: 无; 子程序调用后运算结果的说明
Stack: ; 占用的堆栈层数
History: 无; 修改记录
************************************************************************/
void ex_interrupt_init()
{
EA = 1; //开总中断
EX1 = 1; //开外部中断1
EX0 = 1; //开外部中断0
IT1 = 1; //下降沿触发
IT0 = 1; //下降沿触发
//IT1 = 0; //低电平触发
//IT0 = 0; //低电平触发
}
void main()
{
ex_interrupt_init();
while(1);
}
/************************************************************************
Subroutine: ex_interrupt_service; 子程序名称
Description: 外部中断服务程序; 子程序功能的描述
Principium: 进入一次中断,led翻转一次; 程序设计原理
Calls: 无; 被本子程序调用的子程序清单
Variables: 无; 本子程序中所用到的临时变量
Input: 无; 子程序调用所需要基本参数的说明
Output: 无; 子程序调用后运算结果的说明
Stack: ; 占用的堆栈层数
History: 无; 修改记录
************************************************************************/
void ex0_interrupt_service() interrupt 0 using 1 //interrupt关键字为中断号,using为寄存器组
{
LED_RUN = ~LED_RUN; //亮灭循环
}
/******************************同上*************************************/
void ex1_interrupt_service() interrupt 2 using 1 //interrupt关键字为中断号,using为寄存器组
{
LED_RUN1 = ~LED_RUN1; //亮灭循环
}
复制代码
联系方式:
QQ:2842481126
QQ群: 375907913
任何关于此文件技术类问题可以在上述QQ中交流探讨!!!谢谢!!!
key_interrupt.rar
2016-7-9 11:24 上传
点击文件名下载附件
下载积分: 黑币 -5
22.75 KB, 下载次数: 5, 下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1