/***************************************************
Copyright: 2014-02-11.version1.0File name: timer.cDescription: 定时中断控制的流水灯Author: lxlVersion: version1.0Date: 2014.02.11History: 无****************************************************/#include <reg51.h>char a=0xff;int num=0;/*************************************************Function: init()Description: 定时中断初始化功能Calls: 无Called By: main()Table Accessed: 无Table Updated: 无Input: void Output: 无Return: void Others: 无*************************************************/void init(void){ TMOD=0x01; EA=1; ET0=1; TH0=(65536-50000)/256; TL0=(65536-50000)%256; TR0=1;}/*************************************************Function: main()Description: 程序的主函数Calls: init()Called By: 无Table Accessed: 无Table Updated: 无Input: void Output: 无Return: void Others: 无*************************************************/void main(void){ init(); while(1) { P1=a; }}void tr() interrupt 1{ TH0=(65536-50000)/256; TL0=(65536-50000)%256; num++; if(num==20) { num=0; a--; if(a==0x00) a=0xff; } }