三星单片机AD转换程序
扫描二维码
随时随地手机看文章
ADR0.EQU05H
ADR1.EQU06H
ADR2.EQU07H
ADR3.EQU08H
CNTR0.EQU10H
ORG0000H
VECTOR00H,INT_9454
ORG003CH
DB00H
DB00H
DB0E7H;允许低电平复位LVR=2.3V
DB00H;选用外部晶振4M
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;ORG0040H
;CODE_TABLE:DB44H,46H,48H,4AH,4DH;0-4度
;DB4FH,51H,54H,56H,58H;5-9度
;DB5BH,5DH,60H,62H,64H;10-14度
;
;LDR4,#00H
;LDR5,#3FH
;AD_FIND:INCR5
;LDCR10,@RR4
;CPR10,A_DATA
;JRULT,AD_FIND
;SUBR10,#40H
;LDLED_D,R10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ORG0044H
CODE_TABLE:DB0,0;44H-45H
DB1,1;46H-47H
DB2,2;48H-49H
DB3,3,3;4AH-4BH-4CH
DB4,4;4DH-4EH
DB5,5;4FH-50H
DB6,6,6;51H-52H-53H
DB7,7;54H-55H
DB8,8;56H-57H
DB9,9,9;58H-59H-5AH
DB10,10;5BH-5CH
DB11,11,11;5DH-5EH-5FH
DB12,12;60H-61H
DB13,13,13;62H-63H-64H
DB14,14;65H-66H
DB15,15,15;67H-68H-69H
DB16,16;6AH-6BH
DB17,17;6CH-6DH
DB18,18;6EH-6FH-70H
DB19,19;71H-72H
ORG0100H
RESET:DI
LDSP,#00C0H
LDBTCON,#10100010B
LDCLKCON,#00001000B;允许外部晶振?CPU分频FOSC/8
CLRP0
CLRP1
CLRP2
LDP0CONL,#10101011B;P0.0AD输入转换
LDP0CONH,#10100000B;P0.6P0.7推拉式输出,数码管1选通、数码管2选通
LDP1CON,#00001010B;p0.0p0.1输出
LDP2CONL,#00001010B;p2.0p2.1P2.2P2.3推拉式输出abcd
LDP2CONH,#01001010B;P2.4P2.5P2.6推拉式输出efg
CLRR10
CLRR11
CLRR12
LDADR0,#10;10*400us=4ms
LDT0DATA,#200
LDT0CON,#10001010B;8/4*200=400us
LDR0,#0A0H
CLRRAM:CLR@R0
DECR0
JRNZ,CLRRAM
CLR@R0
LDADCON,#00000101B
AD_WAIT:TMADCON,#00001000B
JRZ,AD_WAIT
LDA_DATA,ADDATAH
MAIN:EI
ORBTCON,#02H
CPA_DATA,#44H;超出范围,报错
JRULT,LED_W
CPA_DATA,#72H;未定义
JRUGT,LED_W
LDR4,#00H
LDR5,A_DATA
LDCR10,@RR4
ADR10:LDCNTR0,@R10
XORCRTL_R0,#04H
TMCRTL_R0,#04H
JRNZ,AD_H;屏蔽低4位
AD_L:ANDCNTR0,#0FH
LDADR1,CNTR0
JRLED_
AD_H:ANDCNTR0,#0F0H
LDADR2,CNTR0
RCF
RLADR2
RLADR2
RLADR2
RLADR2
RCF
JRADR10
LED_W:LDADR1,#10
LDADR2,#10
LED_:ANDP0,#80H;P0.7高电平,个位数码管停止
ORP0,0BFH;P0.6低电平,十位数码管选通
LDLED_D,ADR2
LED_0:LDR2,#0AH
LDR3,#LED_D
LDCR12,@RR2
LDP2,R12;十位数送给p2口
CALLT0_WAIT
XORCRTL_R0,#02H
TMCRTL_R0,#02H
JRZ,LED_
ANDP0,#7FH;P0.7低电平,个位数码管选通
ORP0,#40H;P0.6高电平,十位数码管停止
LDLED_D,ADR1
JRLED_0
T0_WAIT:TMCRTL_R0,#01H
JRZ,T0_WAIT
DECADR0
JRNZ,T0_WAIT
RET
ORG0A00H
CODE_LED:DB40H,7CH,24H,30H,19H,12H,02H,78H,00H,10H,06H
;"0""1""2""3""4""5""6""7""8""9""E"
INT_9454:ORBTCON,#02H
TMT0CON,#01H
JRZ,INTRET
ORCRTL_R0,#01H
INTRET:IRET
.END