diff --git a/MCU/MCU_3 _TIM_Interrupt/Listings/MCU_1.m51 b/MCU/MCU_3 _TIM_Interrupt/Listings/MCU_1.m51 new file mode 100644 index 0000000..5f381e6 --- /dev/null +++ b/MCU/MCU_3 _TIM_Interrupt/Listings/MCU_1.m51 @@ -0,0 +1,377 @@ +BL51 BANKED LINKER/LOCATER V6.22.2.0 03/30/2022 21:25:24 PAGE 1 + + +BL51 BANKED LINKER/LOCATER V6.22.2.0, INVOKED BY: +C:\KEIL_V5\C51\BIN\BL51.EXE .\Objects\main.obj, .\Objects\delay.obj, .\Objects\led_num.obj TO .\Objects\MCU_1 PRINT (.\L +>> istings\MCU_1.m51) + + +MEMORY MODEL: LARGE + + +INPUT MODULES INCLUDED: + .\Objects\main.obj (MAIN) + .\Objects\delay.obj (DELAY) + .\Objects\led_num.obj (LED_NUM) + C:\KEIL_V5\C51\LIB\C51L.LIB (?C_STARTUP) + C:\KEIL_V5\C51\LIB\C51L.LIB (?C?IMUL) + C:\KEIL_V5\C51\LIB\C51L.LIB (?C?ULDIV) + C:\KEIL_V5\C51\LIB\C51L.LIB (?C?SLDIV) + C:\KEIL_V5\C51\LIB\C51L.LIB (?C?ULCMP) + C:\KEIL_V5\C51\LIB\C51L.LIB (?C?LSTXDATA) + C:\KEIL_V5\C51\LIB\C51L.LIB (?C_INIT) + + +LINK MAP OF MODULE: .\Objects\MCU_1 (MAIN) + + + TYPE BASE LENGTH RELOCATION SEGMENT NAME + ----------------------------------------------------- + + * * * * * * * D A T A M E M O R Y * * * * * * * + REG 0000H 0008H ABSOLUTE "REG BANK 0" + IDATA 0008H 0001H UNIT ?STACK + + * * * * * * * X D A T A M E M O R Y * * * * * * * + XDATA 0000H 000CH UNIT ?XD?LED_NUM + XDATA 000CH 000AH UNIT ?XD?MAIN + XDATA 0016H 0004H UNIT _XDATA_GROUP_ + XDATA 001AH 0003H UNIT ?XD?HELLO_FULL_DISPLAY?LED_NUM + XDATA 001DH 0002H UNIT ?XD?_GET_VAR?LED_NUM + + * * * * * * * C O D E M E M O R Y * * * * * * * + CODE 0000H 0003H ABSOLUTE + CODE 0003H 0008H UNIT ?PR?MAIN?MAIN + CODE 000BH 0003H ABSOLUTE + CODE 000EH 00FDH UNIT ?C?LIB_CODE + CODE 010BH 00C9H UNIT ?PR?HELLO_DISPLAY?LED_NUM + CODE 01D4H 009FH UNIT ?PR?IFLIGHT?MAIN + CODE 0273H 009DH UNIT ?PR?HELLO_FULL_DISPLAY?LED_NUM + CODE 0310H 008CH UNIT ?C_C51STARTUP + CODE 039CH 0060H UNIT ?PR?PULSE?MAIN + CODE 03FCH 0056H UNIT ?PR?NUM_DISPLAY?LED_NUM + CODE 0452H 0051H UNIT ?PR?_GET_VAR?LED_NUM + CODE 04A3H 0044H UNIT ?C?LDIV + CODE 04E7H 002BH UNIT ?C_INITSEG + CODE 0512H 0029H UNIT ?PR?SETCONFIG?MAIN + CODE 053BH 0012H UNIT ?PR?NUM_PUSH?LED_NUM + CODE 054DH 000FH UNIT ?PR?HELLO_PUSH?LED_NUM + CODE 055CH 000EH UNIT ?PR?_DELAY?DELAY + CODE 056AH 0007H UNIT ?PR?LEDFULL?LED_NUM + + BL51 BANKED LINKER/LOCATER V6.22.2.0 03/30/2022 21:25:24 PAGE 2 + + + + +OVERLAY MAP OF MODULE: .\Objects\MCU_1 (MAIN) + + +SEGMENT XDATA_GROUP + +--> CALLED SEGMENT START LENGTH +------------------------------------------------------ +?C_C51STARTUP ----- ----- + +--> ?PR?MAIN?MAIN + +--> ?C_INITSEG + +?PR?MAIN?MAIN ----- ----- + +--> ?PR?SETCONFIG?MAIN + +--> ?PR?IFLIGHT?MAIN + +?PR?IFLIGHT?MAIN 0016H 0004H + + + +SYMBOL TABLE OF MODULE: .\Objects\MCU_1 (MAIN) + + VALUE TYPE NAME + ---------------------------------- + + ------- MODULE MAIN + C:0000H SYMBOL _ICE_DUMMY_ + D:0090H PUBLIC P1 + D:00B0H PUBLIC P3 + B:00A8H.7 PUBLIC EA + D:00A8H PUBLIC IE + D:00B8H PUBLIC IP + X:000CH PUBLIC TH + X:000EH PUBLIC TL + C:0003H PUBLIC main + C:0512H PUBLIC setConfig + C:039CH PUBLIC pulse + X:0010H PUBLIC count + D:0098H PUBLIC SCON + D:0089H PUBLIC TMOD + D:0088H PUBLIC TCON + B:00A8H.1 PUBLIC ET0 + X:0014H PUBLIC var + C:01D4H PUBLIC ifLight + D:008CH PUBLIC TH0 + D:008AH PUBLIC TL0 + B:0088H.4 PUBLIC TR0 + D:00C8H PUBLIC T2CON + X:0015H PUBLIC enable + D:00D0H PUBLIC PSW + ------- PROC SETCONFIG + C:0512H LINE# 13 + C:0512H LINE# 14 + C:0512H LINE# 15 + C:051BH LINE# 16 + C:0522H LINE# 17 + C:0529H LINE# 18 + BL51 BANKED LINKER/LOCATER V6.22.2.0 03/30/2022 21:25:24 PAGE 3 + + + C:052EH LINE# 20 + C:0531H LINE# 22 + C:0533H LINE# 23 + C:0535H LINE# 24 + C:0537H LINE# 26 + C:053AH LINE# 27 + ------- ENDPROC SETCONFIG + ------- PROC PULSE + C:039CH LINE# 29 + C:03B3H LINE# 32 + C:03BCH LINE# 33 + C:03C2H LINE# 34 + C:03C8H LINE# 35 + C:03E7H LINE# 36 + ------- ENDPROC PULSE + ------- PROC IFLIGHT + ------- DO + X:0016H SYMBOL time + ------- DO + X:0018H SYMBOL i + ------- ENDDO + ------- ENDDO + C:01D4H LINE# 38 + C:01D4H LINE# 39 + C:01D4H LINE# 40 + C:01DDH LINE# 41 + C:01DDH LINE# 43 + C:01F7H LINE# 44 + C:01F7H LINE# 46 + C:022CH LINE# 47 + C:022CH LINE# 49 + C:0233H LINE# 50 + C:0254H LINE# 51 + C:025AH LINE# 52 + C:025CH LINE# 53 + C:025CH LINE# 54 + C:026DH LINE# 56 + C:0272H LINE# 57 + C:0272H LINE# 58 + ------- ENDPROC IFLIGHT + ------- PROC MAIN + C:0003H LINE# 61 + C:0003H LINE# 62 + C:0003H LINE# 64 + C:0006H LINE# 65 + C:0006H LINE# 66 + C:0006H LINE# 67 + C:0009H LINE# 68 + ------- ENDPROC MAIN + ------- ENDMOD MAIN + + ------- MODULE DELAY + C:0000H SYMBOL _ICE_DUMMY_ + C:055CH PUBLIC _delay + ------- PROC _DELAY + D:0006H SYMBOL i + C:055CH LINE# 3 + BL51 BANKED LINKER/LOCATER V6.22.2.0 03/30/2022 21:25:24 PAGE 4 + + + C:055CH LINE# 5 + C:055CH LINE# 6 + C:0569H LINE# 7 + ------- ENDPROC _DELAY + ------- ENDMOD DELAY + + ------- MODULE LED_NUM + C:0000H SYMBOL _ICE_DUMMY_ + D:0080H PUBLIC P0 + D:0090H PUBLIC P1 + D:00A0H PUBLIC P2 + D:00B0H PUBLIC P3 + C:0273H PUBLIC hello_full_display + D:00A8H PUBLIC IE + D:00B8H PUBLIC IP + X:0000H SYMBOL count + C:03FCH PUBLIC num_display + D:0098H PUBLIC SCON + D:0088H PUBLIC TCON + C:054DH PUBLIC hello_push + X:0002H PUBLIC hello_var + X:0008H SYMBOL e + D:00C8H PUBLIC T2CON + X:0009H SYMBOL i + C:056AH PUBLIC ledfull + C:0452H SYMBOL _get_var + C:010BH PUBLIC hello_display + C:053BH PUBLIC num_push + D:00D0H PUBLIC PSW + X:000BH SYMBOL var2 + ------- PROC _GET_VAR + X:001DH SYMBOL k + C:0452H LINE# 9 + C:045AH LINE# 10 + C:045AH LINE# 11 + C:04A2H LINE# 12 + ------- ENDPROC _GET_VAR + ------- PROC HELLO_DISPLAY + C:010BH LINE# 19 + C:010BH LINE# 20 + C:010BH LINE# 21 + C:011DH LINE# 22 + C:011DH LINE# 23 + C:0120H LINE# 24 + C:0129H LINE# 25 + C:0130H LINE# 26 + C:0133H LINE# 28 + C:0136H LINE# 29 + C:013FH LINE# 30 + C:0146H LINE# 31 + C:0149H LINE# 33 + C:014CH LINE# 34 + C:0155H LINE# 35 + C:015CH LINE# 36 + C:015FH LINE# 38 + C:0162H LINE# 39 + C:016BH LINE# 40 + BL51 BANKED LINKER/LOCATER V6.22.2.0 03/30/2022 21:25:24 PAGE 5 + + + C:0172H LINE# 41 + C:0175H LINE# 43 + C:0178H LINE# 44 + C:0181H LINE# 45 + C:0188H LINE# 46 + C:018BH LINE# 48 + C:018EH LINE# 49 + C:0196H LINE# 50 + C:019DH LINE# 51 + C:01A0H LINE# 56 + C:01A0H LINE# 57 + C:01AFH LINE# 58 + C:01AFH LINE# 59 + C:01B2H LINE# 61 + C:01B2H LINE# 62 + C:01C0H LINE# 63 + C:01CFH LINE# 64 + C:01D3H LINE# 66 + ------- ENDPROC HELLO_DISPLAY + ------- PROC HELLO_PUSH + C:054DH LINE# 68 + C:054DH LINE# 69 + C:054DH LINE# 71 + C:055BH LINE# 77 + ------- ENDPROC HELLO_PUSH + ------- PROC NUM_DISPLAY + C:03FCH LINE# 79 + C:03FCH LINE# 80 + C:03FCH LINE# 81 + C:040BH LINE# 82 + C:040BH LINE# 84 + C:040EH LINE# 85 + C:0414H LINE# 86 + C:041BH LINE# 87 + C:041EH LINE# 92 + C:041EH LINE# 93 + C:042DH LINE# 94 + C:042DH LINE# 95 + C:0430H LINE# 96 + C:0430H LINE# 97 + C:043EH LINE# 98 + C:044DH LINE# 99 + C:0451H LINE# 101 + ------- ENDPROC NUM_DISPLAY + ------- PROC NUM_PUSH + C:053BH LINE# 104 + C:053BH LINE# 105 + C:053BH LINE# 106 + C:054CH LINE# 107 + ------- ENDPROC NUM_PUSH + ------- PROC LEDFULL + C:056AH LINE# 109 + C:056AH LINE# 110 + C:056AH LINE# 111 + C:056DH LINE# 112 + C:0570H LINE# 113 + ------- ENDPROC LEDFULL + BL51 BANKED LINKER/LOCATER V6.22.2.0 03/30/2022 21:25:24 PAGE 6 + + + ------- PROC HELLO_FULL_DISPLAY + ------- DO + X:001AH SYMBOL var3 + X:001BH SYMBOL j + ------- ENDDO + C:0273H LINE# 116 + C:0273H LINE# 117 + C:0273H LINE# 118 + C:0282H LINE# 119 + C:0282H LINE# 120 + C:0288H LINE# 122 + C:028DH LINE# 123 + C:028DH LINE# 124 + C:029EH LINE# 125 + C:02A0H LINE# 126 + C:02B3H LINE# 127 + C:02BAH LINE# 128 + C:02BDH LINE# 129 + C:02DCH LINE# 134 + C:02DCH LINE# 135 + C:02EBH LINE# 136 + C:02EBH LINE# 137 + C:02EEH LINE# 139 + C:02EEH LINE# 140 + C:02FCH LINE# 141 + C:030BH LINE# 142 + C:030FH LINE# 144 + ------- ENDPROC HELLO_FULL_DISPLAY + ------- ENDMOD LED_NUM + + ------- MODULE ?C?IMUL + C:000EH PUBLIC ?C?IMUL + ------- ENDMOD ?C?IMUL + + ------- MODULE ?C?ULDIV + C:005CH PUBLIC ?C?ULDIV + ------- ENDMOD ?C?ULDIV + + ------- MODULE ?C?SLDIV + C:04A3H PUBLIC ?C?SLDIV + ------- ENDMOD ?C?SLDIV + + ------- MODULE ?C?ULCMP + C:00EEH PUBLIC ?C?ULCMP + ------- ENDMOD ?C?ULCMP + + ------- MODULE ?C?LSTXDATA + C:00FFH PUBLIC ?C?LSTXDATA + ------- ENDMOD ?C?LSTXDATA + +*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS + SEGMENT: ?PR?HELLO_DISPLAY?LED_NUM + +*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS + SEGMENT: ?PR?HELLO_PUSH?LED_NUM + +*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS + BL51 BANKED LINKER/LOCATER V6.22.2.0 03/30/2022 21:25:24 PAGE 7 + + + SEGMENT: ?PR?NUM_DISPLAY?LED_NUM + +*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS + SEGMENT: ?PR?NUM_PUSH?LED_NUM + +*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS + SEGMENT: ?PR?LEDFULL?LED_NUM + +*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS + SEGMENT: ?PR?HELLO_FULL_DISPLAY?LED_NUM + +Program Size: data=9.0 xdata=31 code=1393 +LINK/LOCATE RUN COMPLETE. 6 WARNING(S), 0 ERROR(S) diff --git a/MCU/MCU_3 _TIM_Interrupt/MCU_1.uvopt b/MCU/MCU_3 _TIM_Interrupt/MCU_1.uvopt new file mode 100644 index 0000000..4ff87f2 --- /dev/null +++ b/MCU/MCU_3 _TIM_Interrupt/MCU_1.uvopt @@ -0,0 +1,248 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc; *.md + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + MCU_1 + 0x0 + MCS-51 + + 24000000 + + 1 + 1 + 1 + 0 + 0 + + + 0 + 65535 + 0 + 0 + 0 + + + 120 + 65 + 8 + .\Listings\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 1 + 0 + 1 + + 255 + + + 0 + Data Sheet + DATASHTS\ATMEL\AT89C51_DS.PDF + + + 1 + Instruction Set Manual + DATASHTS\ATMEL\AT_C51ISM.PDF + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + + + + + + + + + + + BIN\MON51.DLL + + + + 0 + DLGTP51 + (98=-1,-1,-1,-1,0)(82=-1,-1,-1,-1,0)(83=-1,-1,-1,-1,0)(84=-1,-1,-1,-1,0)(85=-1,-1,-1,-1,0)(80=-1,-1,-1,-1,0)(91=-1,-1,-1,-1,0)(92=-1,-1,-1,-1,0) + + + 0 + MON51 + -S2 -B115200 -O15 + + + + + + 0 + 1 + i + + + + 0 + + + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + + + + + + + SRC + 1 + 0 + 0 + 0 + + 1 + 1 + 1 + 0 + 0 + 0 + .\main.c + main.c + 0 + 0 + + + + + INC + 1 + 0 + 0 + 0 + + 2 + 2 + 1 + 0 + 0 + 0 + .\delay.c + delay.c + 0 + 0 + + + 2 + 3 + 1 + 1 + 0 + 0 + .\led_num.c + led_num.c + 0 + 0 + + + +
diff --git a/MCU/MCU_3 _TIM_Interrupt/MCU_1.uvproj b/MCU/MCU_3 _TIM_Interrupt/MCU_1.uvproj new file mode 100644 index 0000000..c51ac4b --- /dev/null +++ b/MCU/MCU_3 _TIM_Interrupt/MCU_1.uvproj @@ -0,0 +1,405 @@ + + + + 1.1 + +
### uVision Project, (C) Keil Software
+ + + + MCU_1 + 0x0 + MCS-51 + 0 + + + AT89C51 + Microchip + IRAM(0-0x7F) IROM(0-0xFFF) CLOCK(24000000) + + "LIB\STARTUP.A51" ("Standard 8051 Startup Code") + + 2976 + REGX51.H + + + + + + + + + + + 0 + 0 + + + + Atmel\ + Atmel\ + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + MCU_1 + 1 + 0 + 1 + 1 + 1 + .\Listings\ + 0 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + 65535 + + + S8051.DLL + + DP51.DLL + -p51 + S8051.DLL + + TP51.DLL + -p51 + + + + 0 + 0 + 0 + 0 + 16 + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + + + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + + 0 + 0 + + + + + + + + + + + + + + BIN\MON51.DLL + + + + + 0 + 0 + 0 + 0 + 0 + -1 + + 0 + + "" () + + + + + 0 + + + + 2 + 0 + 2 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + 0 + 0x0 + 0xffff + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x1000 + + + 0 + 0x0 + 0x80 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + + + 0 + 0 + 1 + 0 + 1 + 3 + 8 + 2 + 1 + 1 + 0 + 0 + + + + + ..\MCU + + + + 0 + 1 + 0 + 0 + + + + + + + + + 0 + 0 + 1 + 0 + 2 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SRC + + + main.c + 1 + .\main.c + + + + + INC + + + delay.c + 1 + .\delay.c + + + led_num.c + 1 + .\led_num.c + + + + + + + +
diff --git a/MCU/MCU_3 _TIM_Interrupt/delay.c b/MCU/MCU_3 _TIM_Interrupt/delay.c new file mode 100644 index 0000000..9681197 --- /dev/null +++ b/MCU/MCU_3 _TIM_Interrupt/delay.c @@ -0,0 +1,7 @@ +#include "delay.h" + +void delay(int i) + +{ + for(i = 14; i > 0; i--); +} \ No newline at end of file diff --git a/MCU/MCU_3 _TIM_Interrupt/delay.h b/MCU/MCU_3 _TIM_Interrupt/delay.h new file mode 100644 index 0000000..ae46cf9 --- /dev/null +++ b/MCU/MCU_3 _TIM_Interrupt/delay.h @@ -0,0 +1,7 @@ +#ifndef _DELAY_H_ +#define _DELAY_H_ + + +void delay(int i); + +#endif \ No newline at end of file diff --git a/MCU/MCU_3 _TIM_Interrupt/led_num.c b/MCU/MCU_3 _TIM_Interrupt/led_num.c new file mode 100644 index 0000000..ce0e333 --- /dev/null +++ b/MCU/MCU_3 _TIM_Interrupt/led_num.c @@ -0,0 +1,144 @@ +#include +#include "led_num.h" +#include +#include "delay.h" + +#define DUTY 10 +static unsigned int i = 0; +const unsigned char hello_var[] = {0x89, 0x86, 0xc7, 0xc7, 0xc0,0xff}; +static unsigned char get_var(int k) +{ + return hello_var[(65535-i+k)%6]; +} + + +static unsigned char var2 = 0xfd; +static unsigned int count = 0; +static unsigned char e = 0xfe; + +void hello_display() +{ + if(count < DUTY) + { + P0 = 0xfe; + P2 = get_var(5); + delay(1); + P2 = 0XFF; + + P0 = 0xfd; + P2 = get_var(4); + delay(1); + P2 = 0XFF; + + P0 = 0xfb; + P2 = get_var(3); + delay(1); + P2 = 0XFF; + + P0 = 0xf7; + P2 = get_var(2); + delay(1); + P2 = 0XFF; + + P0 = 0xef; + P2 = get_var(1); + delay(1); + P2 = 0XFF; + + P0 = 0xdf; + P2 = get_var(0); + delay(1); + P2 = 0XFF; + +// var2 = var2 >> 1; +// if(var2 == 0) +// var2 = 0x10; + } + if(count >= DUTY) + { + P2 = 0XFF; + + } + count++; + if(count >= 100) + count = 0; + return; +} + +void hello_push() +{ +// var2 = _crol_(var2, 1); + i++; +// if(var2 < 0xdf) +// { +// i = 0; +// var2 = 0xfd; +// } +} + +void num_display() +{ + if(count < DUTY) + { + + P0 = 0xfe; + P2 = e; + delay(1); + P2 = 0XFF; + +// var2 = var2 >> 1; +// if(var2 == 0) +// var2 = 0x10; + } + if(count >= DUTY) + { + P2 = 0XFF; + } + count++; + if(count >= 100) + count = 0; + return; +} + + +void num_push() +{ + e = _crol_(e, 1); +} + +void ledfull() +{ + P2 = 0xff; + P0 = 0X00; +} + + +void hello_full_display() +{ + if(count < DUTY) + { + unsigned char var3=0xfd; + int j; + for(j=0;j<5;j++) + { + var3 = _crol_(var3,1); + P1=var3; + P2 = hello_var[i]; + delay(1); + P2 = 0XFF; + } + +// var2 = var2 >> 1; +// if(var2 == 0) +// var2 = 0x10; + } + if(count >= DUTY) + { + P2 = 0XFF; + + } + count++; + if(count >= 100) + count = 0; + return; +} \ No newline at end of file diff --git a/MCU/MCU_3 _TIM_Interrupt/led_num.h b/MCU/MCU_3 _TIM_Interrupt/led_num.h new file mode 100644 index 0000000..bf50b78 --- /dev/null +++ b/MCU/MCU_3 _TIM_Interrupt/led_num.h @@ -0,0 +1,15 @@ +#ifndef _LED_NUM_H_ +#define _LDE_NUM_H_ + +void hello_display(); + +void hello_push(); + +void num_display(); + +void num_push(); + + + +#endif + diff --git a/MCU/MCU_3 _TIM_Interrupt/main.c b/MCU/MCU_3 _TIM_Interrupt/main.c new file mode 100644 index 0000000..049fb0e --- /dev/null +++ b/MCU/MCU_3 _TIM_Interrupt/main.c @@ -0,0 +1,69 @@ +#include +#include +#include "delay.h" + +unsigned long int count = 0; +unsigned char var = 0xFF; +#define RELOAD (65535-46080) +int TH, TL; +unsigned char enable = 0; + + + +void setConfig() +{ + TH = RELOAD / 256; + TL = RELOAD - (RELOAD / 256) * 256; + TH0 = TH; + TL0 = TL; + + TMOD = 0x01; //使用定时器T0,高4位全为0,低4位GATE=0,C/T=0,采用工作方式1,M1=0,M1=1 + + TR0 = 1; //启动定时器0 + EA = 1; //打开中断总开关 + ET0 = 1; //打开定时器0中断开关 + + P1 = 0X00; +} + +void pulse() interrupt 1 +{ + + TL0 += TL; + TL0 += 19; + enable = 1; + count++; +} + +void ifLight() +{ + if(enable) + { + int time; + for(time = 1; time < 9; time++) //时间匹配 + { + + if(count % (20 * time) == 0) //是否整数倍 + { + + int i = 1; + i = i << (time - 1); + var = var ^ i; + P1 = var; + } + } + + enable = 0; + } +} + + +int main() +{ +//P1 灯 + setConfig(); + while(1) + { + ifLight(); + } +}