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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/03/04 19:01
Read: times


 
#78628 - MORSE not working
hey guys
you might not like me starting a new subject but I have a deadline next weekend...

I wrote the code with help from a philips file and some notes from you but it doen not work and I cant figure out why.

Could you help me?

the code:



#include 8051.H

;-------constant declaration------------------

TX_LED	.equ	P1.7



;-------Main routine----------------------------

	.org	0000H
Main	acall	Init		; initialise
run	acall	M_OUT
	sjmp	run
	.end


;-------SUB routines--------------------------------

Init	mov	TMOD,	#021h 	; Timer 1 in Auto-reload mode, timer 0 in 16 bit mode
	mov 	IE,	#000h 	; reset interrupts
	setb	ES		; enable serial interrupt
	mov 	PCON,	#080h	; set SMOD for 19200 baud  @11.0592 MHz
	mov	SCON,	#050h	; serial mode 1, REN=1
	mov	TH1,	#253	; load T1 for 19200 baud
	mov	TH0,	#0B4h	; set T0 for 0.05 sec @11.0592 MHz
	mov	TL0,	#095h	;
	setb	TR1		; start timer
	ret			; return


M_OUT	mov	A,	R6	; caracter index
	mov	DPTR,	#STRING	; get string info
	movc	A,	@A+DPTR	; get caracter
	jnz	M_CONV		; jump to morse convert if A is a caracter
	mov	R6,	#00H	; reset caracter index
	mov	R7,	#00H	; reset bit index
	ret			; return

M_CONV				; in: ASCII caracter out: Packed Morse caracter
	subb	A,	#20	; normalize for space=0
	push	DPH		; push DataPointerHigh
	push	DPL		; push DataPointerLow
	mov	DPTR,	#MORSE	; get morse info
	movc	A,	@A+DPTR	; get morse caracter
	pop	DPH		; pop DPTRH
	pop	DPL		; pop DPTRL
	cjne	A,#00H,	PARSE	; loop for spaces
	acall	DELAY
	acall	DELAY	
	acall	DELAY
	inc	DPTR		; next string caracter
	sjmp	M_OUT		; keep on going for the whole message



PARSE	mov	R7,	#07H	; init bit pointer
SEEK	rl	A		; 
	dec	R4		; Update bit pointer         
	jnb	ACC.7,	ST_BIT	; If bit is '0', got it!
	sjmp	SEEK		; Go back to find start bit
ST_BIT	RL	a		; Get element
	jnb	ACC.7,	DOTOUT	; If a 0, send dot else sent dash



DASHOUT	mov	R5,	#03h	; Set up for three dots timing
	acall	TX		; Send out 3 Dots= dash            
	sjmp	DONEBIT		; Done with this element
DOTOUT	mov	R5,	#01H	; Set up for one dot timing
	acall	TX		; Send out 1 Dot
DONEBIT	djnz	R7,	ST_BIT	; Keep going if elements remain.
	acall	DELAY		; Put in inter-character spacing
	acall	DELAY		; Put in inter-character spacing
	ret			; All finished with character.


TX	setb	TX_LED		; turn on
	acall	DELAY		; wait
	djnz	R5,	TX	; sent 1 or 3 dots (dot or dash)
	clr	TX_LED		; turn of
	acall	DELAY		; wait
	ret

DELAY	MOV	R2,#0AH		; Outer loop delay counter.
LOOP	setb    TR0		; Start timer
	jnb	TF0,$		; Wait for timer overflow.
	clr	TR0		; Stop timer.
	djnz	R2,	LOOP	; nested delay.
	mov	TH1,	#253	; load T1 for 19200 baud
	mov	TH0,	#0B4h	; set T0 for 0.05 sec @11.0592 MHz
	ret			; Done with time delays.


;-------Interrupt routines---------------------------------

;-------Tables---------------------------------------------

MORSE

	.DB	000H,0CAH,085H,0D6H	; SPACE,AR,SK,KN
	.DB	0D1H,0FFH,0FFH,0FFH	; BT,??,??,??
	.DB	0FFH,0FFH,0FFH,0FFH	; ??,??,??,??    
	.DB	0B3H,0FFH,095H,0D2H	; ,,??,.,/
	.DB	0DFH,0CFH,0C7H,0C3H	; 0,1,2,3
	.DB	0C1H,0C0H,0D0H,0D8H	; 4,5,6,7
	.DB	0DCH,0DEH,0FFH,0FFH	; 8,9,??,??
	.DB	0FFH,0FFH,0FFH,08CH	; ??,??,??,?
	.DB	0FFH,0F9H,0E8H,0EAH	; ??,A,B,C
	.DB	0F4H,0FCH,0E2H,0F6H	; D,E,F,G
	.DB	0E0H,0F8H,0E7H,0F5H	; H,I,J,K
	.DB	0E4H,0FBH,0FAH,0F7H	; L,M,N,O
	.DB	0E6H,0EDH,0F2H,0F0H	; P,Q,R,S
	.DB	0FDH,0F1H,0E1H,0F3H	; T,U,V,W
	.DB	0E9H,0EBH,0ECH		; X,Y,Z





STRING

	.DB	'C','Q','C','Q',' ','S','A','W',' ','G','A',' '
	.DB	'N','A','A','R',' ','C','O','O','R','D','I','N','A','A','T',' '
	.DB	'1','2','3','.','4','5','-','1','2','3','.','4','5',' ','E','I','N','D','E'
	.DB	00H 			;END CODE
	.END


List of 13 messages in thread
TopicAuthorDate
MORSE not working            01/01/70 00:00      
   RE: MORSE not working            01/01/70 00:00      
   RE: MORSE not working            01/01/70 00:00      
   RE: MORSE not working            01/01/70 00:00      
   RE: MORSE not working            01/01/70 00:00      
   RE: MORSE not working            01/01/70 00:00      
      RE: MORSE not working            01/01/70 00:00      
         RE: MORSE not working            01/01/70 00:00      
            Step-by-Step            01/01/70 00:00      
            RE: MORSE not working            01/01/70 00:00      
               RE: MORSE not working            01/01/70 00:00      
                  RE: MORSE not working            01/01/70 00:00      
   RE: MORSE not working            01/01/70 00:00      

Back to Subject List