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_REAL _FINAL/main.c

91 lines
1.5 KiB
C
Raw Normal View History

2022-05-19 13:07:52 +00:00
#include "main.h"
#define RELOAD (65535-9216) //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ(1ms)
unsigned char TH, TL;
extern Menu *NOW; //<2F>˵<EFBFBD>ָ<EFBFBD><D6B8>
2022-06-05 13:03:15 +00:00
extern enum OPR opr; //<2F><><EFBFBD><EFBFBD>״̬
unsigned char freshScreenTriger = 0;
void int0() interrupt 0 //<2F>ⲿ<EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
{
// IE0 = 0; //<2F><><EFBFBD><EFBFBD>
// delay(20);
// IE0 = 0;
//
// if(PIN_3 == 0)
// {
// delay(10);
// if(PIN_3 == 0)
// opr = left;
// }
// else if(PIN_3 == 1)
// {
// delay(10);
// if(PIN_3 == 1)
// opr = right;
// }
unsigned char LS, CS, flag = 0;
LS = PIN_3;
while(!PIN_1)
{
CS = PIN_3;
flag = 1;
}
if(flag == 1)
{
if((LS == 0) && (CS == 1))
opr = right;
if((LS == 1) && (CS == 0))
opr = left;
}
}
void time() interrupt 1 //<2F><>ʱ<EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD>ϰ<EFBFBD><CFB0><EFBFBD>
{
EA = 0;
TH0 = TH;
TL0 = TL0 + TL;
TL0 = TL0 + 23;
if(PIN_4 == 0)
{
delayms(15);
if(PIN_4 == 0)
opr = confirm;
}
EA = 1;
}
2022-05-19 13:07:52 +00:00
int main()
{
TH = RELOAD / 256; //<2F><><EFBFBD><EFBFBD>ֵԤ<D6B5><D4A4><EFBFBD><EFBFBD>
TL = RELOAD - (RELOAD / 256) * 256;
TH0 = TH;
TL0 = TL;
TMOD = 0x01; //ʹ<>ö<EFBFBD>ʱ<EFBFBD><CAB1>T0<54><30><EFBFBD><EFBFBD>4λȫΪ0,<2C><>4λGATE=0<><30>C/T=0<><30><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD>ʽ1<CABD><31>M1=0,M1=1
TR0 = 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>0
EA = 1; //<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>ܿ<EFBFBD><DCBF><EFBFBD>
ET0 = 1; //<2F>򿪶<EFBFBD>ʱ<EFBFBD><CAB1>0<EFBFBD>жϿ<D0B6><CFBF><EFBFBD>
IT0 = 1; //<2F>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD>ʽΪ<CABD>±<EFBFBD><C2B1>ش<EFBFBD><D8B4><EFBFBD>
EX0 = 1; //<2F><><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD>ж<EFBFBD>0
EA = 1; //<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>ܿ<EFBFBD><DCBF><EFBFBD>
displayInit(); //<2F><>Ļ<EFBFBD><C4BB>ʼ<EFBFBD><CABC>
clear();
menuInit(); //<2F>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
2022-05-19 13:07:52 +00:00
while(1)
{
2022-05-19 13:07:52 +00:00
2022-06-05 13:03:15 +00:00
NOW->f(NOW);
}
2022-05-19 13:07:52 +00:00
}