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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
James Brzycki
02/27/13 20:35
Read: 1011 times
Hammond
Us


 
#189505 - Works
Responding to: James Brzycki's previous message
ok so it works just fine now. As for the pointer going past three counts and into 54H im not sure but i found another student that did the same thing and his also has the double bar "||". I will still re-post the code.

...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,#90H			; place cursor at thso position
	ACALL	COMNWRT
	ACALL	DELAY
	DEC	R1
	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
	DEC	R1
	MOV	A,@R1
	ACALL	DATAWRT
	ACALL	DELAY
	DEC	R1
	MOV	A,@R1
	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	R6,A
	ANL	A,#0F0H
	MOV	P2,A
	CLR	P3.7
	SETB	P3.6
	ACALL	DELAY
	CLR	P3.6
	MOV	A,R6
	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	R6,A
	ANL	A,#0F0H
	MOV	P2,A
	SETB	P3.7
	SETB	P3.6
	ACALL	DELAY
	CLR	P3.6
	MOV	A,R6
	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      James Brzycki      02/24/13 09:46      
   Comments, please      Hal Albach      02/24/13 17:25      
      Comments      James Brzycki      02/24/13 17:56      
         Code Fragments      Hal Albach      02/24/13 21:01      
            Commenst added, reply to hal      James Brzycki      02/24/13 21:11      
               comments      Hal Albach      02/24/13 22:46      
                  comments      James Brzycki      02/25/13 06:33      
                     Program flow      Hal Albach      02/25/13 11:40      
                        comments      James Brzycki      02/25/13 21:45      
                           Clarification & Suggestions      Hal Albach      02/26/13 07:44      
                              GREAT HELP      James Brzycki      02/26/13 11:39      
                                 Data Display loop      Hal Albach      02/26/13 12:24      
                                    Worked sorta      James Brzycki      02/27/13 06:57      
                                       The output      Hal Albach      02/27/13 15:29      
                                          I looked at it wrong      James Brzycki      02/27/13 17:19      
                                             Works      James Brzycki      02/27/13 20:35      
                                                Great news!      Hal Albach      02/28/13 07:05      
                                                   Thank you      James Brzycki      02/28/13 07:15      
                                                      You're Welcome      Hal Albach      02/28/13 08:33      
                                                      A couple of questions      Hal Albach      02/28/13 11:06      
                                                         Answers and questions      James Brzycki      02/28/13 11:54      
                                                            Thanks      Hal Albach      02/28/13 12:36      

Back to Subject List