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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
Hal Albach
02/24/13 21:01
Read: 895 times
Seminole, Florida
USA


 
#189457 - Code Fragments
Responding to: James Brzycki'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      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