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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/09/11 02:35
Modified:
  08/09/11 03:03

Read: times


 
#183267 - need help to display timer count on hyperterminal and LED'S
Hi, I was wondering if i could get some help with my assembly code. I am using a function generator for timer 0 and need to display the count in binary on the LED's and the equivalent ASCII value on hyper-terminal. Port 1 is attached to the dip switches to control the maximum count and port 2 is attached to the LED's.

	RAM_ADDR	EQU	40H
	ASCI_RSULT	EQU	50H
	COUNT		EQU	3
	ORG	0000H
	MOV	TMOD, #00000110B	;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
	LCALL	BIN_DEC_CONVRT	
	LCALL	DEC_ASCI_CONVRT
	MOV	TMOD, #20H              ;TIMER 1 MODE 2
	MOV	TH1, #0FDH              ;9600 BAUD RATE
	MOV	SCON, #50H              ;8-BIT, 1 STOP BIT, REN ENABLED
	SETB	TR1                     ;START TIMER 1
	LCALL	SEND
	JNB	TF0, BACK1
	CLR	TF0			;CLEAR TIMER 0 FLAG
	SJMP	AGAIN
	

;-------CONVERTING BIN(HEX) TO DEC (00-FF TO 000-255)

BIN_DEC_CONVRT:
	MOV	R0, #RAM_ADDR
	MOV	A, P2
	MOV	B, #10
	DIV	AB
	MOV	@R0, B
	INC	R0
	MOV	B, #10
	DIV	AB
	MOV	@R0, B
	INC	R0
	MOV	@R0, A
	RET
	
;-------CONVERTING DEC DIGITS TO DISPLAYABLE ASCII DIGITS

DEC_ASCI_CONVRT:
	MOV	R0, #RAM_ADDR
	MOV	R1, #ASCI_RSULT
	MOV	R2, #3
BACK:	MOV	A, @R0
	ORL	A, #30H
	MOV	@R1, A
	INC	R0
	INC	R1
	DJNZ	R2, BACK
	RET
	
;-------SERIAL DATA TRANSFER.

SEND:	MOV	SBUF, 50H
	MOV	SBUF, 51H
	MOV	SBUF, 52H
H_1:	JNB	TI, H_1
	CLR	TI
	RET
	END 

 


If i comment out the call instructions and timer 1 the timer 0 count is displayed on the LED bank and nothing is displayed on hyper-terminal, so i know that portion of the code works. the problem i am running into is that when i leave those instructions, the LED bank no longer displays the count and i get the wrong count on hyper-terminal. If anyone could look over my code and send me in the right direction for a solution i would very much appreciate it.

thank you

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