This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/MCU/MCU_4 _Wave/main.c

87 lines
1,006 B
C
Raw Normal View History

2022-04-07 14:02:15 +00:00
#include <reg52.h>
#include <intrins.h>
#include "delay.h"
#include "main.h"
void num_display()
{
P0 = 0xfe;
P2 = num_var[ge];
delay(1);
P2 = 0XFF;
P0 = 0xfd;
P2 = num_var[ui];
delay(1);
P2 = 0XFF;
P0 = 0xfb;
P2 = num_var[bd];
delay(1);
P2 = 0XFF;
P0 = 0xf7;
P2 = num_var[qm];
delay(1);
P2 = 0XFF;
P0 = 0xef;
P2 = num_var[wj];
delay(1);
P2 = 0XFF;
P0 = 0xdf;
P2 = 0xff;
delay(1);
P2 = 0XFF;
}
void time() interrupt 1
{
TH0 = 0X4C;
TL0 = 0X0D;
if(count == 20)
{
EA = 0;
TR1 = 0;
count = 0;
return;
}
// enable = 1;
count++;
}
int main()
{
//P1 <20><>
setConfig();
while(1)
{
if(EA == 0)
{
num = TH1 * 256 + TL1;
wj = num / 10000;
qm = (num % 10000) / 1000;
bd = (num % 1000) / 100;
ui = (num % 100) / 10;
ge = num % 10;
TL1=0X00;
TH1=0X00;
EA = 1;
TR1 = 1;
}
num_display();
}
}