This ASCII to Morse code table is here for anyone wishing to make use of it for their own projects.
This table snippet is useful for users of HAM radio and for students interested in coding in assembler for embedded microcontrollers such as the Microchip PIC. The assembler code (as shown here) has been cleaned-up and can be adapted for use by the pic10, pic12, pic16 or higher processors, and anyone familiar enough with programming could possibly adapt it for another processor type if they like by substituting equivalent pointers, indexes and DB statements.
Seemed like an improvement worth sharing. Various examples seen on the internet use a split code method which uses 5 bits of the byte for the code, and 3 bits for a bit counter. This method allows you to use 1 to 7 bits by using a flag bit to signify end of morse code. First time this method was seen was in alt.microcontrollers.8bit, August 2, 2002, "Re: New Grad Hiring Test - Are you really a firmware coder?" but I'm sure this sort of method has been done many times before using various micro processors.
Anyhow, still thinking of the "Are you a firmware coder?" - Seems worth leaving the code shown as-is and let you challenge yourself to finish-up the rest to be the way you see fit for your own use. ;-)
If you find this following code of interest, you'll want to compare and verify it with Morse Code description to make sure you have the latest codes.
You can download ASCII to MORSE ASM table, or you can copy and paste the code shown below into your ASM code editor.
;**************************************************************** ;ASCII to MORSE Code Table for ASCII{21h..5Fh} ;This table uses a single-byte encoding similar to one published ;in QST Feb 97 which shifted data right until it ended-up with a ;value of one. The code here is similar in method and works on ;the PIC microcontroller in a shift-left manner. ;NOTE: Consider this code table and sample pseudo code a starting ;point if you want to build yourself a morse code generator and ;learn some ASM coding too. ; ;MorseCode Generator Table - 2011Nov01 - by J Da Silva ; t_morse addwf PCL,f ;go fetch data retlw b'10101110'-1 ;21h "!" -.-.-- or ---. retlw b'01001010'-1 ;22h """ .-..-. retlw 0FFh ;23h "#" retlw b'00010011'-1 ;24h "$" ...-..- retlw 0FFh ;25h "%" retlw b'01000100'-1 ;26h "&" .-... (same as wait) retlw b'01111010'-1 ;27h "'" .----. retlw b'10110100'-1 ;28h "(" -.--. retlw b'10110110'-1 ;29h ")" -.--.- retlw 0FFh ;2Ah "*" retlw b'01010100'-1 ;2Bh "+" .-.-. retlw b'11001110'-1 ;2Ch "," --..-- retlw b'10000110'-1 ;2Dh "-" -....- retlw b'01010110'-1 ;2Eh "." .-.-.- retlw b'10010100'-1 ;2Fh "/" -..-. retlw b'11111100'-1 ;30h "0" ----- retlw b'01111100'-1 ;31h "1" .---- retlw b'00111100'-1 ;32h "2" ..--- retlw b'00011100'-1 ;33h "3" ...-- retlw b'00001100'-1 ;34h "4" ....- retlw b'00000100'-1 ;35h "5" ..... retlw b'10000100'-1 ;36h "6" -.... retlw b'11000100'-1 ;37h "7" --... retlw b'11100100'-1 ;38h "8" ---.. retlw b'11110100'-1 ;39h "9" ----. retlw b'11100010'-1 ;3Ah ":" ---... retlw b'10101010'-1 ;3Bh ";" -.-.-. retlw 0FFh ;3Ch ">" retlw b'10001100'-1 ;3Dh "=" -...- retlw 0FFh ;3Eh "<" retlw b'00110010'-1 ;3Fh "?" ..--.. retlw b'01101010'-1 ;40h "@" (=A+C) .--.-. retlw b'01100000'-1 ;41h "A" .- retlw b'10001000'-1 ;42h "B" -... retlw b'10101000'-1 ;43h "C" -.-. retlw b'10010000'-1 ;44h "D" -.. retlw b'01000000'-1 ;45h "E" . retlw b'00101000'-1 ;46h "F" ..-. retlw b'11010000'-1 ;47h "G" --. retlw b'00001000'-1 ;48h "H" .... retlw b'00100000'-1 ;49h "I" .. retlw b'01111000'-1 ;4Ah "J" .--- retlw b'10110000'-1 ;4Bh "K" -.- retlw b'01001000'-1 ;4Ch "L" .-.. retlw b'11100000'-1 ;4Dh "M" -- retlw b'10100000'-1 ;4Eh "N" -. retlw b'11110000'-1 ;4Fh "O" --- retlw b'01101000'-1 ;50h "P" .--. retlw b'11011000'-1 ;51h "Q" --.- retlw b'01010000'-1 ;52h "R" .-. retlw b'00010000'-1 ;53h "S" ... retlw b'11000000'-1 ;54h "T" - retlw b'00110000'-1 ;55h "U" ..- retlw b'00011000'-1 ;56h "V" ...- retlw b'01110000'-1 ;57h "W" .-- retlw b'10011000'-1 ;58h "X" -..- retlw b'10111000'-1 ;59h "Y" -.-- retlw b'11001000'-1 ;5Ah "Z" --.. retlw b'10110100'-1 ;5Bh "[" -.--. (sub for "(") retlw 0FFh ;5Ch "\" retlw b'10110110'-1 ;5Dh "]" -.--.- (sub for ")") retlw 0FFh ;5Eh "~" retlw b'00110110'-1 ;5Fh "_" ..--.- ;Additional codes to consider Prosign retlw b'00000000'-1 ;Error ........ retlw b'01000100'-1 ;Wait (also the same code for &) retlw b'10110000'-1 ;Invitation to transmit -.- retlw b'00010110'-1 ;End of work ...-.- retlw b'00010100'-1 ;Understood ...-. retlw b'10101100'-1 ;Starting Signal -.-.- ;**************************************************************** ;pseudo code (not actual code) sendChr call t_morse ;value = get (byte) movwf value incf value,f ;Cflag=0 (error makes Cflag=1) rlf value,w ;Cflag<-(value)<-Cflag loop sendDotOrDash(Cflag) ;(Cflag has dot/dash value) clrc ;shift Cflag<-(value)<-0 rlf value,f ;Zflag set here too loop while value<>0 ;until Zflag==0 exit |
If you use this code for your project, I will appreciate a little credit for putting this together for you and having it available here for your own use/project (for example, in your source code comments, or even a web link back to this web page is great if you have a project that uses it that you want to show/demonstrate). Thanks.
Other PIC Related Pages On This Web Site | ||||
---|---|---|---|---|
Home Page | A/B Long Term Timer | Clear RAM Macro | Cylon Eye | Delay Macro |
Random Number Generator (RNG) | 7.96Hz Sinewave Generator | Software RS232 | Table Array FSR Macro | PicDis Disassembler |