Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Dirgre Columbos
12/05/12 09:12
Read: 1244 times

Msg Score: -1
 -1 Non-Specific question
#188968 - HELP (Digital volt meter) Something wrong!!!
lcd_cmd equ 0800h ;Write COMMAND reg address 0800h
lcd_st equ 0801h ;Read STATUS reg address 0801h
lcd_wr equ 0802h ;Write DATA reg address 0802h
lcd_rd equ 0803h ;Read DATA reg address 0803h

LEDs equ p1 ;LEDs on port 1
DAC equ 0600h ;DAC mapped at address 0600h

ORG 08100h

DVM: mov P2, #(lcd_cmd SHR 8) ;load P2 with high address
mov R0, #(lcd_cmd AND 255) ;load R0 with command reg addr
mov R7, #01h ;set LCD position, line=1, char=3
mov dptr, #mesg1 ;point to mesg1
acall wr_string ;write mesg1 to LCD

mov R7, #41h ;set LCD position, line= 2, char=1
mov dptr, #mesg2 ;point to mesg2
acall wr_string ;write mesg2 to LCD

stop: ajmp stop ;soft halt

wr_string: acall lcd_busy ;wait until LCD not busy
mov a, R7 ;get LCD position
orl a, #080h ;msb set for LCD RAM address
movx @R0, a ;write lcd_cmd to set line & char
acall lcd_busy ;wait until LCD not busy
clr a
movc a, @a+dptr
inc dptr ;point to next byte in string
jz str_end ;if 0 then end of string

mov R1, #(lcd_wr AND 255) ;Load R1 with wr_data address
movx @R1, a ;Write char to LCD
sjmp nxt_char ;get next char in string
str_end: sjmp start0

lcd_busy: mov R1, #(lcd_st AND 255) ;Load R1 with status address
movx a, @R1 ;read LCD status
jb acc.7, lcd_busy ;keep checking until busy bit clear

mesg1: db "SquidProg ",0
mesg2: db "Voltage= ",0


start0: mov dptr,#DAC ;load dptr address of DAC
mov R7,#10000000b ;initialise Event
mov a,#0 ;initialise DAC value
nxtbit: xrl a,r7 ;Ex-OR DAC value with Event
movx @dptr,A ;Output DAC value
;acall delay
jb P3.5,keep ;if comparator +ve keep set bit

xrl a,R7 ;else reset bit
keep: xch a,R7 ;R7?A (move R7 to A so we can rotate it)
clr c ;make sure we put zero in MSB
rrc a ;Rotate R7 right through carry
xch a,R7 ;R7?A (mov A back to R7 & restore A)
jnc nxtbit ; repeat nxtbit until all bit done
cpl a ;invert Dac Value
mov LEDs,a ;write Dac Value to LEDs
ljmp DVM ;Go back and do it again

;delay: mov R0,#0FFh
;loop1: mov R1,#0FFh
;loop2: nop
;djnz R1,loop2


print_hex3: PUSH ACC

ADD A,#HEXstring3-mvcoff3a
mvcoff3a: ACALL char_from_Acc
ADD A,#HEXstring3-mvcoff3b
mvcoff3b: AJMP char_from_Acc
HEXstring3: DB '0123456789ABCDEF' ;'standard' hex string

; 35 bytes, execution time 21 ┬Ás at 12 MHz

char_from_Acc: mov ????

...insert code here

List of 3 messages in thread
HELP (Digital volt meter) Something wrong!!!      Dirgre Columbos      12/05/12 09:12      
   R17 and R32 are wrong!      Kai Klaas      12/05/12 09:40      
      yes      Steve M. Taylor      12/08/12 16:01      

Back to Subject List