org 00h ;--------------register define--------- s0832_cs equ p3.1 ;low status s0832_di equ p3.3 ;low status s0832_do equ p3.4 ;high status s0832_clk equ p3.0 ;low status ;-------------------------------------- temp_0832 equ 0x77 ;adc converter data count_0832 equ 0x76 ;------------------------------------------------------------------------------ mov p2,#0xff ;if p2=>8 leds clr s0832_di ;initial status clr setb s0832_cs ;initial status setb setb s0832_do ;initial status setb(notice) clr s0832_clk ;initial status clr ; call wr_opcode call read_adc mov p2,temp_0832 ;OUTPUT DATA end_0832: jmp end_0832 ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;===============write operate code wr_opcode: ;opcode=110,start bitĦBsglĦB/sign clr s0832_cs ;start bit=1 setb s0832_di setb s0832_clk clr s0832_clk clr s0832_di ; ;single-ended model setb s0832_di setb s0832_clk clr s0832_clk clr s0832_di ; ;select channel-0 clr s0832_di setb s0832_clk clr s0832_clk setb s0832_di ret ;===============read adc data read_adc: mov count_0832,#8 clr a adcbit: setb s0832_clk clr s0832_clk ;bit data output nop mov c,s0832_do rlc a djnz count_0832,adcbit mov temp_0832,a setb s0832_cs ret ;**************************************************************** ;+++++++++++++++numerical transformation;256/3.2=80,data/80 end