首页 > 学院 > 开发设计 > 正文

跑表精确至0.1秒

2019-11-06 07:15:50
字体:
来源:转载
供稿:网友
#include <reg52.h>#define Dataport P0sbit Latch_seg = P2^2;sbit Latch_bit = P2^3;unsigned char bitcode[8] = {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};unsigned char segcode[16] = {0x3F,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7C,0x39,0x5E,0x79,0x71};unsigned char telcode[16] = {0x06,0x07,0x07,0x7d,0x7f,0x06,0x5b,0x66,0x06,0x7f,0x4f,0x00,0x00,0x00,0x00,0x00};unsigned long int j,k;void ISR_R0(void) interrupt 1{ TH0 = 0x8d; TL0 = 0xf0; j++; if(j == 100) { j = 0; k++; }}void delay(unsigned int i){ while(--i);}void tel(){ unsigned int i; while(1) { Dataport = bitcode[i]; Latch_bit = 1; Latch_bit = 0; Dataport = telcode[(i+k)%16]; Latch_seg = 1; Latch_seg = 0; delay(200); i++; if(i == 8) i = 0; }}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表