;VIET CT HIEN THI LEN LED DOAN MOT SO CO CHU SO ;4 KY SO NAY CHUA TRONG CAC O NHO 20H,21H,22H,23H O 20H CHUA SO HANG NGHIN ORG 0000H // DIA CHI BAT DAU CT LJMP MAIN // TRANH VIEC DUNG PHAI CT NGAT ORG 000BH LJMP ISR_T0 ORG 0030H // DIA CHI BAT DAU CUA NGAT TIMER // NHAY TOI CT NGAT // DIA CHI BAT DAU VIET CT CHINH MAIN: MOV TMOD,#01H // CAU HINH TIMER MODE (16BIT) SETB TF0 // EP NGAT TIMER0, TF=0 BAO TRAN VAO CT NGAT DE NAP LAI MOV R7,#0 // DUNG THANH GHI R7 DE XAC DINH LED NAO DUOC BAT MOV IE,#82H //1000 0010B CHO PHEP NGAT,TIMER0 MOV 20H,#1H MOV 21H,#3H MOV 22H,#2H MOV 23H,#4H SJMP $ // CT CHINH KHONG LAM GI HET ISR_T0: CJNE R7,#0,NEXT1 MOV R1,23H VI 23H VAO R1 SJMP TT NEXT1: CJNE R7,#1,NEXT2 MOV R1,22H SJMP TT NEXT2: CJNE R7,#2,NEXT3 MOV R1,21H SJMP TT // KIEM TRA R7 DE BIET LED NAO SANG, R7 KHAC THI NHAY // R7=0 LED0 SANG, CHUYEN NOI DUNG O NHO HANG DOWN // NHAY TOI TT NEXT3: MOV R1,20H TT: LCALL DISPLAYLED // HIEN THI GIA TRI LEN LED INC R7 // TANG GIA TRI R7 CJNE R7,#4,RUN MOV R7,#0 RUN: CLR TR0 MOV TH0,#HIGH(-9216) YEU CAU DE BAI // CAN XOA DE NAP GIA TRI CHO TH0,TL0 // NAP GIA TRI CHO TH0 9216 XAP XI 10000US=10MS THEO MOV TL0,#LOW(-9216) // NAP LAI GIA TRI DO MODE KO TU DONG NAP LAI SETB TR0 // CHO TIMER CHAY RETI // KET THUC CT NGAT DISPLAYLED: MOV A,R7 MOV DPTR,#TABLE MOVC A,@A+DPTR ADD A,R1 MOV DPTR,#0000H MOVX @DPTR,A RET TABLE: DB 0E0H,0D0H,0B0H,070H END