基于51单片机的定时器程序.docxVIP

  • 75
  • 0
  • 约小于1千字
  • 约 2页
  • 2020-11-09 发布于天津
  • 举报
#include // 包含头文件 #define uchar unsigned char #define uint unsigned int //定义 unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66, 0x6d,0x7d, 0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};// 数字编码 sbit P07=P0A7; 〃位定义,使输出有效 uchar temp,num,shi,ge; void delay(uint z) { uint x,y; for(x=z;x0;x--) for(y=110;y0;y--); } //延时 void init() //程序初始化 { P07=0; //使输出有效 TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; EA=1; //总中断开 TR0=1; //定时方式 ET0=1; 〃定时器开 } void main() { while(1); void timer0() interrupt 1 ( uchar temp; TH0=(65536-50000)/256; TL0=(65536-50000)%256; temp++; if(temp==20) //每秒进一次中断 ( te

文档评论(0)

1亿VIP精品文档

相关文档