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:01
Read: times


 
#189457 - Code Fragments
Responding to: ???'s previous message
Did the book happen to mention what was expected on P0 during the code in block BIN_DEC_CONVRT:?


HERE1:
	JNB	EOC,HERE1
	SETB	OE            ; enable ADC output
	ACALL	DELAY
	MOV	A,MYDATA      ; move P0 to A, (conversion data now in Accumulator)
	CLR	OE            ; disable ADC output, (tri-state)
	ACALL	CONVERSION    ; perform a data conversion
	ACALL	DATA_DISPLAY
	SJMP	BACK

 

CONVERSION:
	ACALL	BIN_DEC_CONVRT   ; first of two conversions
	ACALL	DEC_ASCI_CONVRT
	RET
	
BIN_DEC_CONVRT:
	MOV	R0,#RAM_ADDR     
	MOV	A,P0             ; move P0 to A. ADC output connected to P0. ADC output 
	MOV	B,#10            ;    is currently tri-stated. Essentially, 
	DIV	AB               ;    P0 is not connected to anything. Contents of 
	MOV	@R0,B            ;    the Accumulator are indeterminate.
	INC	R0
	MOV	B,#10
	DIV	AB
	MOV	@R0,B
	INC	R0
	MOV	@R0,A
	RET

 


I'm trying to show here how the BIN_DEC_CONVRT: block destroys the data just read from the ADC.

Simply copying code from a book and inserting it into your program without understanding how the code works will always cause problems.

You might try removing the line
	MOV	A,P0             

 
and see where that may take you.

Hal

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