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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/25/13 04:11
Modified:
  02/25/13 04:14

Read: times


 
#189458 - Commenst added, reply to hal
Responding to: ???'s previous message
So here is my code now with comments. To Hal, no the book is not very detailed.You and the other person has said the same thing about destroying the data and after looking at it I would agree so I have taken it out but I get a question mark displayed. I do know that copying it straight from the book doesn't work, most of the code i have taken out of the book didn't work for the LCD so I had to change it around, its just that I didn't understand much of the ADC and conversion, I now know more of what it does and I'm still learning assembly language so some of the stuff I don't understand but am looking it up. You will also notice my comment in block DATA_DISPLAY: about not being sure what to put in a certain spot.

Thanks,
James


...insert code here[ALE	BIT	P1.0 		;ADC port assignments
OE	BIT	P1.1
SC	BIT	P1.2
EOC	BIT	P1.3
MYDATA	EQU	P0
RAM_ADDR	EQU	40H	;for the bin-dec and dec-ascii conversion
ASCI_RSULT	EQU	50H
COUNT	EQU	3

ORG	0H			;start
                                                                                                                                    
	ACALL	LCD_INIT
	MOV	MYDATA,#0FFH		;adc start/ make po a input
	SETB	EOC			;make eoc and input
	CLR	ALE			;clear ale
	CLR	SC			;clear wr
	CLR	OE			;clear rd
BACK:	
	ACALL	DELAY			;make sure the addr is stable
	SETB	ALE			;latch address
	ACALL	DELAY			;delay for fast ds89c4xx chips
	SETB	SC			;start conversion
	ACALL	DELAY			
	CLR	ALE			;clear ale
	CLR	SC			;clear wr
	
HERE:
	JB	EOC,HERE		;wait until done
HERE1:
	JNB	EOC,HERE1		;wait until done
	SETB	OE			;enable rd
	ACALL	DELAY			;wait
	MOV	A,MYDATA		;read data
	CLR	OE			;clear rd for next time
	ACALL	CONVERSION		;hex-ascii conversion
	ACALL	DATA_DISPLAY		;display the data
	SJMP	BACK

CONVERSION:				;bin-ascii conversion subroutines
	ACALL	BIN_DEC_CONVRT
	ACALL	DEC_ASCI_CONVRT
	RET
	
BIN_DEC_CONVRT:
	MOV	R0,#RAM_ADDR		;save dec digits in these ram locations
	MOV	A,P0			;read data from p0
	MOV	B,#10			;b=0A hex (10 dec)
	DIV	AB			;divide by ten
	MOV	@R0,B			;save lower digit
	INC	R0
	MOV	B,#10			;b=0A hex
	DIV	AB			;divide by ten
	MOV	@R0,B			;save the next digit
	INC	R0
	MOV	@R0,A			;save the last digit
	RET
	
DEC_ASCI_CONVRT:
	MOV	R0,#RAM_ADDR		;address of dec data
	MOV	R1,#ASCI_RSULT		;addr of ascii data
	MOV	R2,#3			;count
BACK1:
	MOV	A,@R0			;get dec digit
	ORL	A,#30H			;make it an ascii digit
	MOV	@R1,A			;save it
	INC	R0			;next digit
	INC	R1			;next
	DJNZ	R2,BACK1		;repeat until the last one
	RET

DATA_DISPLAY:				; since my lcd init is not whats in my book i have to change the data display from whats in it
	ACALL	DELAY
	MOV	A,#91H			; place cursor at thso position
	ACALL	COMNWRT
	ACALL	DELAY
	MOV	A,@R1			;this is me guessing that the data is saved to @R1 during the back1: block, not exactly sure should got here
	ACALL	DATAWRT
	ACALL	DELAY
	RET

LCD_INIT:	ACALL	COMNWRT		;lcd initilize and display text
ACALL	DELAY
MOV	A,#38H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#32H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#28H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#0EH
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#01
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#06H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#80H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#'A'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'C' 
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'T'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'U'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'A'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'L'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#87H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#'T'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'E'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'M'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'P'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#0C0H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#'S'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'E'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'T'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#0C4H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#'T'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'E'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'M'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'P'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#94H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#'M'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'O'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'D'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'E'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#0D4H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#'J'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'B'
ACALL	DATAWRT
ACALL	DELAY
RET

COMNWRT:			;for lcd commands
	MOV	R1,A
	ANL	A,#0F0H
	MOV	P2,A
	CLR	P3.7
	SETB	P3.6
	ACALL	DELAY
	CLR	P3.6
	MOV	A,R1
	ANL	A,#0FH
	RL	A
	RL	A
	RL	A
	RL	A
	MOV	P2,A
	CLR	P3.7
	SETB	P3.6
	ACALL	DELAY
	CLR	P3.6
	RET
	
DATAWRT:			;to send data to lcd and display
	MOV	R1,A
	ANL	A,#0F0H
	MOV	P2,A
	SETB	P3.7
	SETB	P3.6
	ACALL	DELAY
	CLR	P3.6
	MOV	A,R1
	ANL	A,#0FH
	RL	A
	RL	A
	RL	A
	RL	A
	MOV	P2,A
	SETB	P3.7
	SETB	P3.6
	ACALL	DELAY
	CLR	P3.6
	RET	
	
DELAY:			;delay per my class
	MOV	R5,#9
H3:	MOV	R4,#242
H2:	MOV	R3,#255
H1:	DJNZ	R3,H1
	DJNZ	R4,H2
	DJNZ	R5,H3
	RET
	
	END



]


List of 22 messages in thread
TopicAuthorDate
How to display data from a ADC0808 to a LCD            01/01/70 00:00      
   Comments, please            01/01/70 00:00      
      Comments            01/01/70 00:00      
         Code Fragments            01/01/70 00:00      
            Commenst added, reply to hal            01/01/70 00:00      
               comments            01/01/70 00:00      
                  comments            01/01/70 00:00      
                     Program flow            01/01/70 00:00      
                        comments            01/01/70 00:00      
                           Clarification & Suggestions            01/01/70 00:00      
                              GREAT HELP            01/01/70 00:00      
                                 Data Display loop            01/01/70 00:00      
                                    Worked sorta            01/01/70 00:00      
                                       The output            01/01/70 00:00      
                                          I looked at it wrong            01/01/70 00:00      
                                             Works            01/01/70 00:00      
                                                Great news!            01/01/70 00:00      
                                                   Thank you            01/01/70 00:00      
                                                      You're Welcome            01/01/70 00:00      
                                                      A couple of questions            01/01/70 00:00      
                                                         Answers and questions            01/01/70 00:00      
                                                            Thanks            01/01/70 00:00      

Back to Subject List