数字电压表
仿真时,调节发现数码管数值不会变想看一下源程序是否有错,求解。ORG 0000HSJMP STARTORG 0030H;******************;
初始化变量;******************START: CLR AMOV 30H,AMOV 31H,AMOV 32H,AMOV 33H,AMOV 34H,AMOV A,#0FFHMOV P0,AMOV P1,AMOV P2,AMOV P3,ALOOP: NOPNOPNOPLCALL DISPLAYLCALL ADCLCALL PROC1LCALL DISPLAYNOPNOPNOPSJMP LOOP;*********************;;AD
转换子程序查询方式;*********************ADC: MOV DPTR,#7FF8HMOVX @DPTR,ANOPNOPNOPJNB P3.2,$MOV DPTR,#7FF8HMOVX A,@DPTRMOV 30H,AMOV DPTR,#7FF8H ;
再次启动MOVX @DPTR,ARET;*********************;
数据处理子程序;*********************PROC1: MOV A,30HMOV B,#51DIV ABMOV 34H,AXCH A,BMOV B,#10MUL ABJB OV,BCD1MOV B,#51DIV ABMOV 33H,AXCH A,BAJMP BCD2BCD1: MOV B,#51DIV ABADD A,#5MOV 33H,AXCH A,BADD A,#5BCD2: MOV B,#10MUL ABJB OV,BCD3MOV B,#51DIV ABMOV 32H,AAJMP BCD4BCD3: MOV B,#51DIV ABADD A,#5MOV 32H,AXCH A,BADD A,#5BCD4: MOV B,#51DIV ABADD A,#5MOV 31H,AAJMP BCD5BCD5: RET;*******************;
显示子程序;*******************DISPLAY:MOV A,#0FEHMOV P2,AMOV A,34HMOV DPTR,#TABLEMOVC A,@A+DPTRORL A,#80H ;
加小数点MOV P1,ALCALL DELAYMOV A, #0FDHMOV P2,AMOV A,33HMOV DPTR, #TABLEMOVC A,@A+DPTRMOV P1,ALCALL DELAYMOV A, #0FBHMOV P2,AMOV A,32HMOV DPTR, #TABLEMOVC A,@A+DPTRMOV P1,ALCALL DELAYMOV A, #0F7HMOV P2,AMOV A,31HMOV DPTR, #TABLEMOVC A,@A+DPTRMOV P1,ALCALL DELAYRETTABLE: DB 3FH,06H,5BH,4FH,66HDB 6DH,7DH,07H,7FH,6FHDELAY: MOV TMOD,#01HMOV TH0,#0FCHMOV TL0,#18HSETB TR0LOOP1: JBC TF0,NOOPSJMP LOOP1NOOP: 0 CLR TR0RET;MOV R6,#94H;D0: MOV R7,#0f9H;D1: DJNZ R7,D1; DJNZ R6,D0; RETEND
一周热门 更多>