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

📄 timer.c

📁 上学时做的一个51单片机按键显示程序
💻 C
字号:
/*
* Copyright(c)2005 - 2009 danise .China
* All rights reserved.
* Redistribution and use in source and bianry forms
* with or without modification ,are permitted provided
* that following conditions are met:
* 
* 1.Redistrubution of source code must retain the 
* above copyright notice,this list of conditions and
* following disclaimer.
* 
* 2.Redistributions in binary form must reproduce the 
* above copyright notice,this list of conditions and 
* following disclaimer in the documentation and /or other
* materials provided with the distribution.
* 
* Alternately, this acknowledgment may appear in the software
* itself,if and wherever such third-party acknowledgements
* normally appear.
*
* This software is designed for key board and led display.
* 
	
*/
#include "./include/datatypes.h"
#include "./include/keyboard.h"
#include "./include/timer.h"
UINT8 clock0 = 0;
UINT8 elapsetime = 0;
UINT16 sreensaveclk = 0;
/*
	Timer0 interrupt server request 
*/
void Timer0ISR(void) interrupt 1
{	
	UINT8 keyVal = 0;
	CPL932_TL0 = 0x6b;
	CPL932_TH0 = 0x71; /*osc 7.3M  , 10 ms  */
	keyVal = GetSafeKeyValue();
	AnalyseKeyVal( keyVal );

}
/*
	Timer1 interrupt server request 
*/
void Timer1ISR(void) interrupt 3
{
	EA = 0;
	CPL932_TL1 = 0x1;
	CPL932_TH1 = 0x0; /*osc 12M  , 10 ms  */

	if (sreensaveclk < 65530)
		sreensaveclk++;
	else
 		sreensaveclk=65530; 

	if(elapsetime<253)
	    elapsetime++;
	else
		elapsetime=254;

	if(clock0>0)
		clock0--;

	EA=1;

	
}
void wait( UINT8 n ) /* n < 255 */
{
	clock0 = n;
	while(clock0){};
}

⌨️ 快捷键说明

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