|
求大神帮忙看一下,最近做的这个秒表,两位显示正常,但是四位的 显示的分钟 就 那个啥了。感谢大神在百忙之中 抽空看下,万分感谢;
#include<reg51.h>
#include<intrins.h>
sbit sck = P2^0;
sbit rck = P2^1;
sbit ds = P2^2;
sbit L1 = P2^7;
sbit L2 = P2^6;
sbit L3 = P2^5;
sbit L4 = P2^4;
sbit L5 = P2^3;
sbit L6 = P3^0;
sbit mr = P3^1;//????? ??????Ч??
#define uint unsigned int
#define uchar unsigned char
uchar seg[] = {0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90};
uchar a,sec,min,hou;
void send_595(uchar date)
{ uchar i;
for(i=1;i<9;i++)
{
ds = date&0x80;
date<<=1;
sck = 0;
sck = 1;
}
rck = 0;
rck = 1;
}
void timer0_isr() interrupt 1
{ uchar j;
L1 = 0;
L2 = 0;
L3 = 0;
L4 = 0;
L5 = 0;
L6 = 0;
TH0 =0X4C;
TL0 =0X00;
a++;
if(a==20)
{
a = 0;
sec++;
}
if(sec>59)
{
sec = 0 ;
min++;
}
if(min>59)
{
min = 0;
}
mr = 0;
mr = 1;
switch(j)
{
case 0: send_595(seg[sec%10]); L1 = 1; break;
case 1: send_595(seg[sec/10]); L2 = 1; break;
case 2: send_595(seg[min%10]); L3 = 1; break;
case 3: send_595(seg[min/10]); L4 = 1; break;
// case 4: send_595(seg[hou%10]); L5 = 1; break;
// case 5: send_595(seg[hou/10]); L6 = 1; break;
}
j++;
if(j==4)
j=0;
}
void timer0_init(void)
{
TMOD = 0X01;
TH0 =0X4C;
TL0 =0X00;
EA = 1;
ET0 = 1;
TR0 = 1;
}
void main()
{
timer0_init();
while(1);
}
|
|