

$Title(Repeater Controller - 87C552 Version)

$Date(04-03-95)

$MOD552

$DEBUG



        ;*******************************************************;

        ;                                                       ;

        ;       Version for DB-51 Experiments                   ;

        ;                                                       ;

        ;*******************************************************;







SPEED   EQU     020H

        

        ORG     8100h



;************************************************************************

;                                  Main Code                            *

;************************************************************************



START:

        MOV     A,TCON          ; Prepare to mask off Timer 1 stuff.

        ANL     A,#0F0H         ; Preserve T1, clear out T0.

        ORL     A,#01H          ; Enable the mode for T0.

        MOV     TCON,A          ; Send back out to TCON.        

        

        MOV     P1,#0H          ; Turn off LEDs



        MOV     PWMP,#10H       ; Set up sidetone frequency to 1.15kHz.



        ;*******************************************************;

        ;                                                       ;

        ;       Send string of characters in Morse. Terminate   ;

        ;       with a '00'                                     ;

        ;                                                       ;

        ;*******************************************************;



CW_ID:

        MOV     DPTR,#STRING    ; Get the message string to be sent.



STR_IT:

        MOV     A,#00H          ; Get string pointer ready for lookup.

        MOVC    A,@A+DPTR       ; Get next character.

        JNZ     CLEAN_IT        ; If non-zero, work with it.

        SJMP    CW_ID           ; Do it forever.



CLEAN_IT:

        

        SUBB    A,#20H          ; Normalize for SPACE = 0       

        

        ACALL   LOOK_IT         ; Look up 'Packed Morse' code.

        ACALL   MORSEOUT        ; Sent out as Morse Code.

        INC     DPTR            ; Increment string pointer.

        SJMP    STR_IT          ; Keep doing until end of message.





;************************************************************************

;*                                                                      *

;*          CW Output Routine - Morse Data is stored in packed format:  *

;*              Character to be sent is passed in Accumulator           *

;*                                                                      *

;*      One byte per character...packed to the right side of the byte.. *

;*         all unused elements to left are a '1', with a '0' preceding  *

;*         the first element of the character. Dots are a '0' while     *

;*         dashes are a '1'.                                            *

;*                                                                      *

;*      Example: R ( dit dah dit )                                      *

;*                                                                      *

;*              Bit 7  6  5  4  3  2  1  0                              *

;*                  1  1  1  1  0  0  1  0                              *

;*                              ^                                       *

;*                           Start Flag                                 *

;*      Note: A character of 00H signifies a space                      *

;*                                                                      *

;************************************************************************



MORSEOUT:

        CJNE    A, #0H, PARSE           ; Look for space only. Jump if not.

        ACALL   STARTWAIT               ; Send out a 3 spaces only.

        ACALL   STARTWAIT               ; Send out a 3 spaces only.    

        ACALL   STARTWAIT               ; Send out a 3 spaces only.            

        RET



PARSE:

        MOV     R4, #07H                ; Initialize bit pointer.



WAITSTART:        

        RL      A                       ; Look for start flag.

        DEC     R4                      ; Update bit pointer.         

        JNB     ACC.7, STARTBIT         ; If bit is '0', got it!



        SJMP    WAITSTART               ; Go back to find start bit.



STARTBIT:

        RL      A                       ; Get element.

        JNB     ACC.7, DOTOUT           ; If a '0', send dot.



DASHOUT:                                ; If a '1', send a dash.

        MOV     R1,#03h                 ; Set up for three dots timing.

        ACALL   SENDDOT                 ; Send out R1 # of Dots.            



        SJMP    DONEBIT                 ; Done with this element.



DOTOUT:

        MOV     R1, #01H                ; Set up for one dot timing.

        ACALL   SENDDOT                 ; Send out R1 # of Dots.





DONEBIT:

        DJNZ    R4,STARTBIT             ; Keep going if elements remain.

        

        ACALL   STARTWAIT               ; Put in inter-character spacing

        ACALL   STARTWAIT               ; Put in inter-character spacing



        RET                             ; All finished with character.





;*****************************************************************************

;                       Timer Set Up Routine                                 *

;         Sets timer value to 50 mS. (1/2 needed for 6-7 WPM)                *

;*****************************************************************************

SETTIME:

                MOV     TH0,#SPEED          ; Put MSByte in Timer High Reload.

                MOV     TL0,#LOW(0-50000)   ; Put LSByte in Timer Low Reload.

                RET                         ; Done with intialization.



;*****************************************************************************

;               Start Wait Routine                                           *

;       Sets up the Timer value...waits for timeout...clrs OVF...and does    *

;       again...thus giving time delay                                       *

;*****************************************************************************

STARTWAIT:

                MOV     R2,#08H         ; Outer loop delay counter.

OUTERLOOP:

                ACALL   SETTIME         ; Set the Timer values.

                SETB    TCON.4          ; Start timer

                JNB     TCON.5,$        ; Wait for timer overflow.

                CLR     TCON.5          ; Stop timer.

                DJNZ    R2,OUTERLOOP    ; nested delay.



;                ACALL   SETTIME         ; Set up timer one last time.

;                SETB    TCON.4          ; Start timer.

;                JNB     TCON.5,$        ; Wait for overflow.

;                CLR     TCON.5          ; Stop timer.

                RET                     ; Done with time delays.



;*****************************************************************************

;               Send DOT Routine                                             *

;               Send out R1 # of DOTs with    a space afterwords             *

;*****************************************************************************

SENDDOT:

                MOV     PWM0,#80H       ; Turn on Oscillator.

                

                MOV     P1,#55H         ; Flash LEDs



                ACALL   STARTWAIT       ; Start timer and wait.

                DJNZ    R1,SENDDOT      ; Send DOT R1 number of times.

                

                MOV     PWM0,#0H        ; Turn off oscillator.

                

                MOV     P1,#0H          ; Turn off LEDs

                

                ACALL   STARTWAIT       ; Start timer and wait (space).





                RET                     ; Done sending Dot(s).



        ;*******************************************************;

        ;                                                       ;

        ;       Character to 'Packed Morse' lookup routine.     ;

        ;       Enter with character to be looked up stripped   ;

        ;       of the 20H...also it is verified to be within   ;

        ;       character bounds. Character to be checked is    ;

        ;       passed in Accumulator, and looked-up value is   ;

        ;       also passed back in the accumulator.            ;

        ;                                                       ;

        ;*******************************************************;



LOOK_IT:

        PUSH    DPH

        PUSH    DPL

        MOV     DPTR,#LOOKUP

        MOVC    A,@A+DPTR

        POP     DPL

        POP     DPH

        RET





        ;*******************************************************;

        ;                                                       ;

        ;  Look up table for the character to 'Packed-Morse     ;

        ;     routine. The table is set up with a SPACE         ;

        ;     character as the first entry. Procedural signs    ;

        ;     as noted.                                         ;

        ;                                                       

        ;*******************************************************;



LOOKUP:

        DB      00H,0CAH,85H,0D6H       ; SPACE,AR,SK,KN

        DB      0D1H,0FFH,0FFH,0FFH     ; BT,??,??,??

        DB      0FFH,0FFH,0FFH,0FFH     ; ??,??,??,??    

        DB      0B3H,0FFH,95H,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,8CH      ; ??,??,??,?

        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      'CQ CQ CQ DE WA3NOA WA3NOA   CQ CQ CQ DE WA3NOA   K',00H





        END



