📄 ext1int.c
字号:
/****************************************************************************/
/* */
/* Copyright (c) 2005, 老树工作室 */
/* All rights reserved. */
/* */
/* Email:laoshu0902@163.com */
/* www.laoshu0902.bokee.com */
/* */
/****************************************************************************/
/****************************************************************************/
/* 文件名:ext1int.c */
/* 版 本:Version 1.0 */
/* 描 述:外部中断1演示代码 */
/* */
/* 作 者:spot */
/* 函 数: */
/* ext1_int_proc */
/* system_init */
/* */
/* 历史记录: */
/* spot 2005-06-25 Creat Inital version. (Version 1.0) */
/****************************************************************************/
#include <reg52.h>
#include <absacc.h>
#include <intrins.h>
typedef unsigned char u_char;
typedef unsigned int u_int;
u_int ext1_count; /* 外部中断1中断计数 */
/* 函数声明 */
void ext1_int_proc(void); /* 外部中断1中断服务程序,使用第2组寄存器 */
void system_init(void); /* 系统上电初始化 */
/* 声明结束 */
/* 外部中断1中断服务程序,使用第2组寄存器 */
void ext1_int_proc(void) interrupt 2 using 2
{
ext1_count++;
}
/* 系统上电初始化 */
void system_init(void)
{
EA = 0; /* CPU 关中断 */
ext1_count = 0; /* 外部中断1计数清零 */
TCON = 0x04; /* 外部中断下降沿触发 */
IE = 0x84; /* 外部中断1,CPU开中断 */
}
main()
{
system_init();
while(1)
{
if (ext1_count >= 3000) /* 外部中断次数大于3000 */
{
ext1_count = 0;
P1 = ~P1;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -