发表于:2009/3/18 19:57:15
#0楼
请教各位大侠:最近用MCP3201做了一个12位串行A/D转换电路,可是怎么修改程序,总是输出0FFFH,不知问题出在哪?望支招
MCP3201: SETB CS
MOV 29H,#15 ;
NOP
NXTBIT: CLR AD_CLK ;X,X,NULL,D11,D10,D9...D0
NOP
CLR CS ; CS low to startconversion or keep low till done
NOP
SETB AD_CLK ; raise the clock
NOP
MOV C,DAT ; put data into C flag
RLC A ; shift C into Acc (A/D low bits)
XCH A,15H ; get ADRESH byte
RLC A ; shift C into Acc (A.D high bits)
XCH A,15H ; get low bits back into Acc for next loop
DJNZ 29H,NXTBIT
MOV 16H,A ; put A into ADRESL
ANL 15H,#0FH ; mask off unwanted bits (x,X,X,Null)
SETB CS ; set CS hi to end conversion
MCP3201: SETB CS
MOV 29H,#15 ;
NOP
NXTBIT: CLR AD_CLK ;X,X,NULL,D11,D10,D9...D0
NOP
CLR CS ; CS low to startconversion or keep low till done
NOP
SETB AD_CLK ; raise the clock
NOP
MOV C,DAT ; put data into C flag
RLC A ; shift C into Acc (A/D low bits)
XCH A,15H ; get ADRESH byte
RLC A ; shift C into Acc (A.D high bits)
XCH A,15H ; get low bits back into Acc for next loop
DJNZ 29H,NXTBIT
MOV 16H,A ; put A into ADRESL
ANL 15H,#0FH ; mask off unwanted bits (x,X,X,Null)
SETB CS ; set CS hi to end conversion
[此贴子已经被作者于2009-3-18 20:02:45编辑过]