;*********************************************************** ;This is basic programs for CS5550A EVALUATE-BOARD ;condition:12MHz,CPU[51] ;Write by RockChen on 2002.1.17 in HoneStar ;*********************************************************** cs equ p1.0 sdi equ p1.1 sdo equ p1.2 sclk equ p1.3 int equ p3.3 ;byte======================================================= tempa equ 30h temph equ 31h tempm equ 32h templ equ 33h ;*********************************************************** org 00h ljmp start org 30h start: clr cs lcall init5550a main: mov a,#0ah ;read cc lcall writebyte ;send command lcall readbyte ;receive bytes high byte first mov temph,a lcall readbyte mov tempm,a lcall readbyte mov templ,a ;exampl:read cc ljmp main ;*********************************************************** ;=========================================================== ;In: ;Out: ;Use: r1,2sp ;Note: ;=========================================================== init5550a: clr ex1 ;close int adin setb sdo clr sdi clr sclk mov r1,#63 setb sdi ;reset serial port init541: setb sclk clr sclk djnz r1,init541 clr sdi setb sclk clr sclk ;make converter in command mode mov a,#0e8h ;0e0h start 5550a with single lcall writeByte ;0e8h start 5550a with continu setb ex1 ret ;=========================================================== ;In: none ;Out: a ;Use: a,r1 ;Note: read one byte[a] from cs5550a ;=========================================================== readbyte: mov r1,#08 ;set count setb sdi ;set sdi to avoid inadvertent readbyte1: mov c,sdo ;read msb first rlc a setb sclk nop clr sclk djnz r1,readbyte1 ret ;=========================================================== ;In: a ;Out: none ;Use: a,r1 ;Note: send one byte[a] to cs5550a ;=========================================================== writebyte: mov r1,#08 ;set count clr sclk writebyte1: rlc a ;send msb first mov sdi,c nop setb sclk nop clr sclk djnz r1,writebyte1 setb sdi ;to one when not transmitting ret ;*********************************************************** end

评论