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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/13/11 09:28
Read: times


 
#183347 - Issues
Responding to: ???'s previous message
There still are some issues with this code (see below) and I also do not understand what timer 0 is used for.

        ORG	0000H
	MOV	TMOD, #00100110B	;TIMER 0 MODE 2, COUNTER
	MOV	TH0, #0			;TH0 = 0
AGAIN:	SETB	TR0			;START TIMER/COUNTER 0
BACK1:	MOV	A, TL0			;A = TL0
	MOV	B, P1			;B = P1
	CJNE	A, B, NEXT		;IF A IS NOT EQUAL TO B GOTO NEXT
	CLR	A			;A = 0
	MOV	TL0, A			;TL0 = A
NEXT:	MOV	P2, A
	ACALL 	CONV                    ;CALL CONVERSION SUBROUTINE
	JNB	TF0, BACK1
	CLR	TF0			;CLEAR TIMER 0 FLAG
	SJMP	AGAIN
		
;-------CONVERTING DEC DIGITS TO DISPLAYABLE ASCII DIGITS

CONV:	MOV	B, #10                 
	DIV	AB
	MOV	R2, B
	MOV	B, #10
	DIV	AB
	ORL	A, #30H
	ACALL	SEND
	MOV	A, R4        ; <=== What is in R4 ???
	MOV	A, B         ; <=== Are you sure that SEND did not change B ???
	ORL	A, #30H
	ACALL	SEND
	MOV	R3, A        ; <=== What is R3 for ???
	MOV	A, R2
	ORL	A, #30H
	ACALL	SEND
	MOV	R2, A        ; <=== What is R2 for ???
	SJMP	AGAIN        ; <=== This will create STACK OVERFLOW and destroy ALL registers !!!
	RET                  ; <=== Because you never get here
;-------SERIAL DATA TRANSFER.

SEND:                        ; <=== No need to initialize the UART every time, do it once at startup
	MOV	TH1, #0FDH              ;9600 BAUD RATE
	MOV	SCON, #50H              ;8-BIT, 1 STOP BIT, REN ENABLED
	SETB	TR1                     ;START TIMER 1
	MOV	SBUF, A      ; <=== It is better to check before sending instead of waiting
H_1:	JNB	TI, H_1      ; <=== for the transmission to complete. This way you can do other
	CLR	TI           ; <=== things in the meantime.
	RET
	END

 


List of 17 messages in thread
TopicAuthorDate
need help to display timer count on hyperterminal and LED'S            01/01/70 00:00      
   Attention to Details            01/01/70 00:00      
      divide by 10            01/01/70 00:00      
         Hundredth digit is quotient of division by 100            01/01/70 00:00      
            thanks            01/01/70 00:00      
               Debugged with pen and paper?            01/01/70 00:00      
                  Debugged            01/01/70 00:00      
                     Decimal or hexadecimal?            01/01/70 00:00      
                        decision            01/01/70 00:00      
                           So take up the challenge then            01/01/70 00:00      
                              agreed            01/01/70 00:00      
                        Actually BCD!!            01/01/70 00:00      
   Oh Details Details            01/01/70 00:00      
      update            01/01/70 00:00      
         Issues            01/01/70 00:00      
            better to check before sending            01/01/70 00:00      
               Even Better....            01/01/70 00:00      

Back to Subject List