Your Potential, My Passion !!!

xiaoxiao2021-04-08  4

// C51 MCU 8155 digital display // Two sets of traffic lights, red lights display 30S, green light display 25S, yellow light displays 5s and flashing. Org 0100h Ajmp Main Main: Mov SP, # 30h setb p3.2 acall init8155 MOV TMOD , # 1 MOV TL0, # 0H MOV IE, # 0 setb TR0 mm: MOV R1, # 1E MOV R2, # 19h MOV P1, # 0f3h // 11110011 setb P3.2 MOV R3, # 19h M1 : ACALL DELAY1 DJNZ R3, M1 ACALL INIT MOV R2, # 05H MOV R1, # 05H MOV P1, # 0f5h setb P3.2 MOV R3, # 05H M2: ACALL DELAY1 CPL P1.1 DJNZ R3, M2 ACALL INIT MOV P1, # 0feh CLR P3.2 MOV R1, # 19h MOV R2, # 19h MOV R3, # 19h M3: ACALL DELAY1 DJNZ R3, M3 MOV P1, # 05H setb p3.2 MOV R1, # 05h MOV R2, # 05H MOV R3 , # 05h m4: ACALL DELAY1 CPL P1.4 DJNZ R3, M4 AJMP MM Delay1: JNB TF0, $ CLR TF0 ACALL Compute Mov 2BH, # 047h loop: MOV DPTR, # Table Mov A, R5 MOVC A, @ A DPTR MOV R0, # 0feh acall display mov a, r4 MOV DPTR, # Table MOVC A, @ A DPTR MOV R0, # 0fdh acall display MOV A, R7 MOV DPTR, # Table MOVC A, @ A DPTR MOV R0, # 0FBH ACALL DISPLAY MOV A, R6 MOV DPTR, # Table MoVC A, @ A DPTR MOV R0, # 0f7h ACALL DISPLAY DJNZ 2BH, LOOP DEC R1 DEC R2 RET COMPUTE: MOV A, R1 MOV B, # 0AH DIV AB MOV R4 , A Mov A, B MOV R 5, A MOV A, R2 MOV B, # 0AH Div AB MOV R6, A MOV A, B MOV R7, A RET Display: MOV 2AH, # 0ffh MOV 2ch, A DIS1: MOV A, 2CH MOV DPTR, # 0f102h MOVX @ DPTR, A MOV DPTR, # 0f101h MOV A, R0 MOVX @ DPTR, A DJNZ 2AH, DIS1 RET INIT: MOV TH0, # 0H MOV TL0, # 0H RET INIT8155: MOV DPTR, # 0f100h MOV A, # 03h MOVX @ DPTR, A RET TABLE: DB 3FH, 06H, 5BH, 4FH, 66H, 6DH, 7DH, 07H, 7FH, 6FH, 77H, 7CH END

转载请注明原文地址: http://www.9cbs.com/read-132875.html

New Post(0)