C语言 单片机实现秒表的控制没有按键只显示分 秒 毫秒什么地方错了? 希望给出答案 谢谢!!!
#include"AT89X52.h"#include<rtx51tny.h>unsignedcharSHUMA[10]={0x3F,0x06,0x5B,0x4F,0x6...
#include "AT89X52.h"
#include <rtx51tny.h>
unsigned char SHUMA[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned long Num;
void Display (void) _task_ 0
{
unsigned int n;
unsigned char min,sec,ms;
os_create_task(1);
while(1)
{
n = Num;
ms = n%100;
n = n/100;
sec = n%60;
min = n/60;
P2_4=0;P2_3=0;P2_2=0;
P0 = SHUMA[ms%10];
os_wait(K_TMO,1,0);
P0 = 0x00;
P2_4=0;P2_3=0;P2_2=0;
P0 = SHUMA[ms/10];
os_wait(K_TMO,1,0);
P0 = 0x00;
P2_4=0;P2_3=0;P2_2=0;
P0 = SHUMA[sec%10] | 0x80;
os_wait(K_TMO,1,0);
P0 = 0x00;//ÏûÒþ
P2_4=0;P2_3=0;P2_2=0;
P0 = SHUMA[sec/10];
os_wait(K_TMO,1,0);
P0 = 0x00;//ÏûÒþ
P2_4=0;P2_3=0;P2_2=0;
P0 = SHUMA[min%10] | 0x80;
os_wait(K_TMO,1,0);
P0 = 0x00;//ÏûÒþ
P2_4=0;P2_3=0;P2_2=0;
P0 = SHUMA[min/10];
os_wait(K_TMO,1,0);
P0 = 0x00;//ÏûÒþ
}
}
void NumAdd (void) _task_ 1
{
while(1)
{
os_wait(K_IVL,10,0);
Num = (Num+1)%1000000;
}
} 展开
#include <rtx51tny.h>
unsigned char SHUMA[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned long Num;
void Display (void) _task_ 0
{
unsigned int n;
unsigned char min,sec,ms;
os_create_task(1);
while(1)
{
n = Num;
ms = n%100;
n = n/100;
sec = n%60;
min = n/60;
P2_4=0;P2_3=0;P2_2=0;
P0 = SHUMA[ms%10];
os_wait(K_TMO,1,0);
P0 = 0x00;
P2_4=0;P2_3=0;P2_2=0;
P0 = SHUMA[ms/10];
os_wait(K_TMO,1,0);
P0 = 0x00;
P2_4=0;P2_3=0;P2_2=0;
P0 = SHUMA[sec%10] | 0x80;
os_wait(K_TMO,1,0);
P0 = 0x00;//ÏûÒþ
P2_4=0;P2_3=0;P2_2=0;
P0 = SHUMA[sec/10];
os_wait(K_TMO,1,0);
P0 = 0x00;//ÏûÒþ
P2_4=0;P2_3=0;P2_2=0;
P0 = SHUMA[min%10] | 0x80;
os_wait(K_TMO,1,0);
P0 = 0x00;//ÏûÒþ
P2_4=0;P2_3=0;P2_2=0;
P0 = SHUMA[min/10];
os_wait(K_TMO,1,0);
P0 = 0x00;//ÏûÒþ
}
}
void NumAdd (void) _task_ 1
{
while(1)
{
os_wait(K_IVL,10,0);
Num = (Num+1)%1000000;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询