list P=16F84 ; ; PIC Specific Equates ; ; C equ 0 ; Carry bit in Status register DC equ 1 ; Decimal Carry bit Status register Z equ 2 ; Zero bit in Status register PD equ 3 ; Power Down bit Status register TO equ 4 ; Timeout bit Status register RP0 equ 5 ; Register Bank Select 0 RP1 equ 6 ; Register Bank Select 1 IRP equ 7 ; Register Bank Select Bit T0IF equ 2 ; T0 Interrupt Flag T0IE equ 5 ; T0 Interrupt Enable ; ; File Register Assignments ; ; INDF equ 00h ; Indirect access phantom register TMR0 equ 01h ; Counter for delay PCL equ 02h ; Program counter STATUS equ 03h ; Status register FSR equ 04h ; Indirect Memory Pointer PORTA equ 05h ; Port A PORTB equ 06h ; Port B EEDATA equ 08h ; EEPROM Data EEADR equ 09h ; EEPROM Address PCLATH equ 0Ah ; PC Latch INTCON equ 0Bh ; Interrupt Control OPT equ 01h ; Option TRISA equ 05h ; TRISB equ 06h ; FLAG equ 0Ch ; Flags WDTCNT equ 0Dh ; Watchdog timer counter R0 equ 10h ; General purpose register R1 equ 11h ; R2 equ 12h ; R3 equ 13h ; R4 equ 14h ; R5 equ 15h ; R6 equ 16h ; ; ; Input/Output Port ; ; DIT_SW equ 00h DAH_SW equ 01h KEY equ 00h ; ; User flags ; ; DAH_FLG equ 00h ; ; Morse equates ; M_END equ 000h ; 0000 0000 M_SKIP equ 001h ; 0000 0001 M_SP equ 002h ; 0000 0010 M_USER equ 003h ; 0000 0011 M_CALL equ 005h ; 0000 0101 M_TO equ 080h ; 1000 0000 M_0 equ 0FCh ; 1111 1100 = 0 = ----- M_1 equ 07Ch ; 0111 1100 = 1 = .---- M_2 equ 03Ch ; 0011 1100 = 2 = ..--- M_3 equ 01Ch ; 0001 1100 = 3 = ...-- M_4 equ 00Ch ; 0000 1100 = 4 = ....- M_5 equ 004h ; 0000 0100 = 5 = ..... M_6 equ 084h ; 1000 0100 = 6 = -.... M_7 equ 0C4h ; 1100 0100 = 7 = --... M_8 equ 0E4h ; 1110 0100 = 8 = ---.. M_9 equ 0F4h ; 1111 0100 = 9 = ----. M_AR equ 054h ; 0101 0100 = AR = .-.-. M_SK equ 016h ; 0001 0110 = SK = ...-.- M_PER equ 056h ; 0101 0110 = . = .-.-.- M_COM equ 0CEh ; 1100 1110 = , = --..-- M_BT equ 08Ch ; 1000 1100 = BT = -...- M_QUE equ 032h ; 0011 0010 = ? = ..--.. M_DN equ 094h ; 1001 0100 = / = -..-. M_CT equ 0ACh ; 1010 1100 = CT = -.-.- M_KN equ 0ACh ; 1010 1100 = KN = -.-.- M_SN equ 014h ; 0001 0100 = SN = ...-. M_A equ 060h ; 0110 0000 = A = .- M_B equ 088h ; 1000 1000 = B = -... M_C equ 0A8h ; 1010 1000 = C = -.-. M_D equ 090h ; 1001 0000 = D = -.. M_E equ 040h ; 0100 0000 = E = . M_F equ 028h ; 0010 1000 = F = ..-. M_G equ 0D0h ; 1101 0000 = G = --. M_H equ 008h ; 0000 1000 = H = .... M_I equ 020h ; 0010 0000 = I = .. M_J equ 078h ; 0111 1000 = J = .--- M_K equ 0B0h ; 1011 0000 = K = -.- M_L equ 048h ; 0100 1000 = L = .-.. M_M equ 0E0h ; 1110 0000 = M = -- M_N equ 0A0h ; 1010 0000 = N = -. M_O equ 0F0h ; 1111 0000 = O = --- M_P equ 068h ; 0110 1000 = P = .--. M_Q equ 0D8h ; 1101 1000 = Q = --.- M_R equ 050h ; 0101 0000 = R = .-. M_S equ 010h ; 0001 0000 = S = ... M_T equ 0C0h ; 1100 0000 = T = - M_U equ 030h ; 0011 0000 = U = ..- M_V equ 018h ; 0001 1000 = V = ...- M_W equ 070h ; 0111 0000 = W = .-- M_X equ 098h ; 1001 1000 = X = -..- M_Y equ 0B8h ; 1011 1000 = Y = -.-- M_Z equ 0C8h ; 1100 1000 = Z = --.. ; ; ******* Main Program ******* ; ; org 0000h goto Start ; ********* MSsendcode *********** ; ; Subroutine : MSsendcode(W) ; Author : N. Putra ; Created : Sept 10-2000 ; Last Update : Sept 13-2000 - better way to make dit and dah ; : Oct 18-2000 - add MSsendcode as alternative ; ; Description : This routine will send Morse code from ; : character in W or send code from W. ; : ; Return value : Nothing ; Register Affected : Flags set accordingly ; : R0 & R1 & R2 destroyed - from MSgetcode & TMdelay ; : ; MSsendcode movwf R0 ; save code clrwdt ; sanity check ok xorlw M_SP ; is it SPACE btfsc STATUS,Z ; goto MSsndsp ; yes, send space MSnxtel movf R0,W ; get back the code addwf R0,F ; shift left, save to R1 and get C btfsc STATUS,Z ; goto MSend ; Zero means end movlw .10 ; 1 el. delay btfsc STATUS,C ; C=0 - it is DIT addlw .20 ; make W = 3 el. delay bsf PORTB,KEY ; turn on tone call TMdelay ; wait until done bcf PORTB,KEY ; turn off tone movlw .10 ; inter el. space call TMdelay ; goto MSnxtel MSsndsp movlw .40 ; additional 4 el. inter word delay goto MSdly ; MSend movlw .20 ; additional 2 el. inter char delay MSdly call TMdelay ; return ; ********* MGsend *********** ; ; Subroutine : MGsend ; Author : N. Putra ; Created : Oct 20-2000 ; Last Update : Oct 18-2000 - better information ; ; Description : This routine will send a message ; : ; : ; Return value : Nothing ; Register Affected : Flags set accordingly ; : R0, R1, R2 & R3 destroyed ; : MGsend clrf R3 ; clear R3 MGNext movf R3,W ; get index to string clrwdt ; sanity check ok call MG_beac ; get the code iorlw 0 ; check for zero btfsc STATUS,Z ; zero means end of string return call MSsendcode ; and send it incf R3,F ; next entry goto MGNext MG_beac addwf PCL,F retlw M_D retlw M_E retlw M_SP retlw M_P retlw M_Y retlw M_2 retlw M_C retlw M_S retlw M_U retlw M_DN retlw M_B retlw M_SP retlw 0 ; ********* TMdelay *********** ; ; Subroutine : TMdelay(W) ; Author : N. Putra ; Created : Sept 10-2000 ; Last Update : Oct 18-2000 - better information ; ; Description : This routine will delay N-morse code element ; : (in W) ; : ; Return value : Nothing ; Register Affected : Flags set accordingly ; : R1 & R2 destroyed ; : TMdelay movwf R1 ; save delay TMoutlp movlw .100 ; inner loop movwf R2 ; TMinlp decfsz R2,F ; goto TMinlp ; decfsz R1,F ; outer loop goto TMoutlp ; retlw 0 Start bsf STATUS,RP0 ; page 1 movlw 0FFh ; port A all inputs tris PORTA ; movlw 00h ; port B all outputs tris PORTB ; movlw 0FFh ; asign prescaler to WDT option ; and set 1:128 rate bcf STATUS,RP0 ; back to page 0 movlw 00h ; make sure TX is not keyed movwf PORTB ; on power up movwf FLAG ; clear flags movlw M_R ; Send Roger and wait for WDT call MSsendcode ; sleep ; BCsend call MGsend ; send the message movlw 5 ; movwf WDTCNT ; BCsleep sleep ; decfsz WDTCNT,F ; goto BCsleep ; goto BCsend END