⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intermit.c

📁 电话单路计费系统!LCD段码显示!电话机设定自由费率,根据反极信号计费及延时计费自由设定!
💻 C
字号:
#include <reg2051.h>
#include "1621_driver.h"
#include "tel_equipment.h"
#include "AT24C08PAGE_Ok.H"


void init(void){
	P1 = 0XFF;
//	P2 = 0XFF;
	P3 = 0XFF;
	ET1 = 1;
	ET0 = 1;
//	PCON |= 0x80;
	IP  = 0X02;						//定义定时0为高优先级中断
	SCON = 0x50;
//	TMOD = 0x21;					//0010,0001	定时器1模式2,定时器0模式0
//	T2CON= 0X04;					//0000,0100	用T1做BOUD发生器
//	TH0 = 0XFD;
//	TL0 = 0XFD;
//	TH1 = 0XFD;						//11.0592_9600
//	TL1 = 0XFD;
//	TH1 = 0XFA;						//22.1184_9600
//	TL1 = 0XFA;
//	TR1 = 1;
	TR0 = 1;
	TR1 = 1;
//	IT0 = 1;						//int0负边沿触发
//	REN = 1;						//Serial接受允许
//	ES  = 1;	
//	EX0 = 1;						//开中断0
	EA  = 1;
	Showbit=1;
	EEReadPage(&p[0],0,linetype,1);
	LineType = p[0];
}
void time0 (void) interrupt 1 using 1{			//提供标准时间
static uchar count;
	if(count == 0xe0){
		if (times == 0x15180)times = 0;
		else times ++;
		count = 0;
//		Led1 = !Led1;
	}
	else count ++;
}
//#pragma OPTIMIZE(6,speed) //the funcion以9极优化,空间压缩为主

void time1 (void) interrupt 3 using 2{
static char count1,count2,count3,count4,count5;
	switch(timetype){
	case 1:
		status1 = 1;
		status2 = 1;
		if (status1 != status2){
			count1 ++;
			count2 = 0;
		}
		else{
			count1 = 0;
			count2 ++;
		}
		if (status1 != status3)
			count3++;
		else
			count3 = 0;
		
		if (count1 == 20)lift_bit = 1;
		if (count2 == 20){
			lift_bit = 0;
			polarity_bit = 0;
		}
		if (count3 >  2)polarity_bit = 1;

		timetype = 2;
		break;
	case 2:
		
		if (count4 == 20 ) {
			count4 =0;
			times3++;
			if ((times3 == 0x80) && !LineType && (nkey > 2))
				polarity_bit = 1;
		}
		else count4 ++;
		timetype = 3;
		break;
	case 3:
		if (!release ) {
			count5 ++;
		}
		else count5 = 0;
		if (count5 == 5) 
			Showbit = 1;
		timetype = 1;
		break;
	default:
		timetype = 1;
		break;
	
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -