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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/05/12 16:12
Read: 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
nxt_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
ret

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
SWAP A

ANL A,#0FH
ADD A,#HEXstring3-mvcoff3a
MOVC A,@A+PC
mvcoff3a: ACALL char_from_Acc
POP ACC
ANL A,#0FH
ADD A,#HEXstring3-mvcoff3b
MOVC A,@A+PC
mvcoff3b: AJMP char_from_Acc
HEXstring3: DB '0123456789ABCDEF' ;'standard' hex string

; 35 bytes, execution time 21 µs at 12 MHz


char_from_Acc: mov ????





end
...insert code here
 



List of 3 messages in thread
TopicAuthorDate
HELP (Digital volt meter) Something wrong!!!            01/01/70 00:00      
   R17 and R32 are wrong!            01/01/70 00:00      
      yes            01/01/70 00:00      

Back to Subject List