??? 10/01/04 07:47 Read: times |
#78477 - RE: MORSE encoder Responding to: ???'s previous message |
there is no need for a PWM
Following an example, which use a simple delay routine. If you want a tone output, simple start and stop T2 in square wave generator mode. Peter <pre> tx_on equ p1.0 delay10ms equ 10000 ;cycle count for 10msec delay at 12MHz dseg at 30h speed: ds 1 cseg init: mov speed, #10 ;morse speed = 10 * 10msec main: acall morsestring db 'Hello World ' db 0 ;0 mark end of string sjmp main signal_on: setb tx_on ret signal_off: clr tx_on ret morsestring: pop dph ;get return address, pop dpl ;point to string sjmp ?mst2 ?mst1: acall morsechar ;send byte inc dptr ;point to next byte ?mst2: clr a movc a, @a+dptr ;get byte jnz ?mst1 ;send if not 0 jmp @a+dptr ;jump after string morsechar: acall morsetable ;ascii to morse code setb c ;acc = 00 after 9 shifts ?mch1: rlc a jnc ?mch1 ;search leading 1 sjmp ?mch4 ?mch2: acall signal_on jnc ?mch3 ;if 0 then skip 2 times delay acall delay2 ;send 3 times: - ?mch3: acall delay1 ;send 1 time : . acall signal_off acall delay1 ?mch4: add a, acc ;shift left with always 0 into ACC.0 jnz ?mch2 ; ajmp delay2 ;pause 3 times until next char delay2: acall delay1 delay1: mov r5, speed ?del1: mov r7, #high(delay10ms/2+253) ;wait 10ms mov r6, #low(delay10ms/2-2) ?del2: djnz r6, ?del2 djnz r7, ?del2 djnz r5, ?del1 ret ;********************** convert ascii to morse code ********************* ; ; Definition of morse code table: ; Since the length can be variable, all bits, ; until the 1. bit which was set, are skipped. ; Then all next bits are send: ; Bit = 0 was send as '.' and bit = 1 was send as '-'. ; Not translated codes are send as space ; morsetable: add a, #-'Z'-1-5 ; <= 'Z'+5 jnc ?mta2 add a, #'Z'-'z' ; <= 'z'+5 jnc ?mta2 ?mta1: clr a ;pause or not defined characters ret ?mta2: add a, #'Z'+1+5-',' ; >= ',' jnc ?mta1 inc a movc a, @a+pc ret db 01110011b ;,: --..-- db 0 ;not defined: 45 db 01010101b ;. = stop: .-.-.- db 0 ;not defined: 47 db 00111111b ;0: ----- db 00101111b ;1: .---- db 00100111b ;2: ..--- db 00100011b ;3: ...-- db 00100001b ;4: ....- db 00100000b ;5: ..... db 00110000b ;6: -.... db 00111000b ;7: --... db 00111100b ;8: ---.. db 00111110b ;9: ----. db 0, 0, 0, 0, 0 ;not defined: 58..62 db 01001100b ;?: ..--.. db 0 ;not defined: 64, 96 db 00000101b ;a: .- db 00011000b ;b: -... db 00011010b ;c: -.-. db 00001100b ;d: -.. db 00000010b ;e: . db 00010010b ;f: ..-. db 00001110b ;g: --. db 00010000b ;h: .... db 00000100b ;i: .. db 00010111b ;j: .--- db 00001101b ;k: -.- db 00010100b ;l: .-.. db 00000111b ;m: -- db 00000110b ;n: -. db 00001111b ;o: --- db 00010110b ;p: .--. db 00011101b ;q: --.- db 00001010b ;r: .-. db 00001000b ;s: ... db 00000011b ;t: - db 00001001b ;u: ..- db 00010001b ;v: ...- db 00001011b ;w: .-- db 00011001b ;x: -..- db 00011011b ;y: -.-- db 00011100b ;z: --.. db 0, 0, 0, 0, 0 ;not defined: 91..95, 123..127 end |
Topic | Author | Date |
MORSE encoder | 01/01/70 00:00 | |
RE: MORSE encoder | 01/01/70 00:00 | |
RE: MORSE encoder | 01/01/70 00:00 | |
RE: MORSE encoder | 01/01/70 00:00 | |
RE: MORSE encoder | 01/01/70 00:00 | |
RE: MORSE encoder | 01/01/70 00:00 | |
RE: MORSE encoder | 01/01/70 00:00 | |
RE: MORSE encoder | 01/01/70 00:00 | |
RE: MORSE encoder | 01/01/70 00:00 | |
RE: MORSE encoder | 01/01/70 00:00 | |
RE: MORSE and Bar Codes | 01/01/70 00:00 | |
Barcode scan speed variation | 01/01/70 00:00 | |
RE: Barcode scan speed variation | 01/01/70 00:00 | |
RE: Barcode scan speed variation | 01/01/70 00:00 | |
RE: Barcode scan speed variation | 01/01/70 00:00 | |
RE: Barcode scan speed variation | 01/01/70 00:00 | |
RE: Barcode Wand reader | 01/01/70 00:00 | |
RE: Barcode Wand reader | 01/01/70 00:00 | |
RE: Barcode Wand reader![]() | 01/01/70 00:00 | |
RE: MORSE encoder | 01/01/70 00:00 | |
RE: MORSE encoder | 01/01/70 00:00 | |
RE: MORSE encoder | 01/01/70 00:00 |