--=====================_77697906==_ Content-Type: text/plain; charset="us-ascii"; format=flowed Er, James said I'd used an improper tag. Here's another posting.. >Sometimes only a look inside can solve a problem. My 1-pin debugger has >saved my bacon on many occasions. > >I've enclosed a WORKING program for PIC12C508 which contains a routine >called MORSE. It can be spliced into any PIC processor. Just make sure the >16-place table winds up in a good table area (won't run over an FF to 00 >boundary). It sings out the contents of the W-reg upon entry into the MORSE > routine. > >The pin goes HIGH when the MORSE pulses are generated, normally low. So >connecting the RED wire of a small piezo noisemaker (BLK on GND) will allow >the morse code to be heard. If you are NOT familiar with Morse Code it's >easy to learn, especially since you only need to learn the 16 hex characters. > >The routine will first send out the MS Nibble (0..F), a small wait, then >the LS Nibble (0..F) or the Wreg when the MORSE routine was entered, then >return. > >Any Q's? please email me. I also have a single-pin diagnostic that is used >for production testing (sends out 8 critical bytes), but its too complex >for a simple splice. For a link to learning MORSE CODE, checkout http://www.babbage.demon.co.uk/morseabc.html >Enjoy! > >--Bob -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads --=====================_77697906==_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: attachment; filename="morse.asm" ;**************************************************** ; Written By Bob Axtell (cr_axtell@yahoo.com) ; May be used without permission!! ; A demo for the use of MORSE routine without ; an interrupt. Clock speed is 32.76Khz. ; ; The routine MORSE sends out standard MORSE CODE (positive ; pulses) of the following hex chars: '0'..'9', 'A'..'F' ; based on the content of W when MORSE is entered, out Pin A1 ; of GPIO. The way I used it was to drive a tiny piezo buzzer, ; like Radio Shack used to sell (the TINY 3V ones). I know ; Morse Code well (I was a ham) but one could easily interpret ; the output with a program on a PC. ; ; This program is for a handheld remote which sends ; a burst of control pulses acording to its ADR out ; to a 433Mhz RF Transmitter then turns itself off ; (resets a CMOS 4001 flipflop at 9V). This guy never ; paid me, and 3 years has gone by, so.. enjoy. ; ; The routine will work with the most primitive to the ; smartest PIC, just change to a port pin of your choice ; ;--Bob ;**************************************************** LIST LIST P=PIC12C509A ;========================================================================== w equ h'0000' f equ h'0001' ;----- Register Files ----------------------------------------------------- indf equ h'0000' tmr0 equ h'0001' pcl equ h'0002' status equ h'0003' fsr equ h'0004' osccal equ h'0005' gpio equ h'0006' ;A0= Reset Strobe To Reset CD4001 _-_ (I) ;A1= Morse Beeper Output (O) ;A2= Data to Transmitter (O) ;A3= Unused (I) ;A4= Unused (I) ;A5= Unused (I) ;----- STATUS Bits -------------------------------------------------------- gpwuf equ h'0007' pa0 equ h'0005' not_to equ h'0004' not_pd equ h'0003' z equ h'0002' dc equ h'0001' c equ h'0000' ;----- OPTION Bits -------------------------------------------------------- not_gpwu equ h'0007' not_gppu equ h'0006' t0cs equ h'0005' t0se equ h'0004' psa equ h'0003' ps2 equ h'0002' ps1 equ h'0001' ps0 equ h'0000' ;----- OSCCAL Bits -------------------------------------------------------- oscfst equ h'0003' oscslw equ h'0002' ;========================================================================== ; RAM Definition ;========================================================================== __maxram h'1f' ;========================================================================== ; ; Configuration Bits ; ;========================================================================== _mclre_off equ h'0fef' _cp_off equ h'0fff' _wdt_on equ h'0fff' _lp_osc equ h'0ffc' _extrc_osc equ h'0fff' ; list ; __CONFIG h'0fec' ; ; MACROS FOLLOW delay1 macro clrwdt nop nop nop nop nop endm delay2 macro clrwdt nop nop nop nop nop nop nop nop nop nop nop nop endm delay3 macro clrwdt nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop endm ; normal active ram tmp equ h'07' tmp1 equ h'08' tmp2 equ h'09' flags equ h'0a' ;only A7 used save1 equ h'0b' ;morse only (3) save2 equ h'0c' savew equ h'0d' ; output stream num1 equ h'0e' num2 equ h'0f' num3 equ h'10' ; LIST ;+++++++++++++++++++++++++++++++++++++++++++++++ ; Macros ; set lower bank bank0 macro bcf status,5 endm ; set upper bank bank1 macro bsf status,5 endm ;=========================================== ; program begins ;=========================================== start: goto start1 rev: retlw h'02' ;rev date retlw h'01' adrvl: retlw h'01' ;address value, 16 bits adrvh: retlw h'00' var1: retlw h'00' var2: retlw h'00' var3: retlw h'00' ; ; Copyright notice went here ; org h'40' ;code protection from here forward ;******************************************************************* ;morse jump table mtable addwf pcl,f retlw h'bf' ;0 101 11111 1=L, 0=S retlw h'be' ;1 101 11110 retlw h'bc' ;2 101 11100 retlw h'b8' ;3 101 11000 retlw h'b0' ;4 101 10000 retlw h'a0' ;5 101 00000 retlw h'a1' ;6 101 00001 retlw h'a3' ;7 101 00011 retlw h'a7' ;8 101 00111 retlw h'af' ;9 101 01111 retlw h'42' ;a 010 00010 retlw h'81' ;b 100 00001 retlw h'85' ;c 100 00101 retlw h'61' ;d 011 00001 retlw h'20' ;e 001 00000 retlw h'84' ;f 100 00100 ; morse debug routine: flash out w value on porta,0 morse: movwf savew ;save w in savew bsf flags,7 ;clear flg ;ms nibble movwf save2 swapf save2,f ;and in save2 MS ; both nibbles use same procedure mxmit: movf save2,w andlw h'f' ;4 bits only call mtable ; send out nibble movwf save2 movwf save1 swapf save1,f rrf save1,w andlw 7 movwf save1 ;count in save1 mxmit0: bsf gpio,1 movlw d'60' ;try short rrf save2,f btfsc status,c ; so, long wait movlw d'180' call wait bcf gpio,1 movlw d'120' call wait decfsz save1,f goto mxmit0 call wait100 btfss flags,7 goto wait100 bcf flags,7 movf savew,w ;savew > save2 movwf save2 goto mxmit wait100:movlw d'255' wait: movwf tmp ; wait= = .5ms/count delay: clrwdt ;delay decfsz tmp,f goto delay retlw 0 ;*************************************************************** ; pickup start again start1: nop movlw h'c8' ;option reg option ;A0= Reset Strobe To Reset CD4001 _-_ (I) ;A1= Morse Beeper Output (O) ;A2= Data to Transmitter (O) movlw b'11111001' tris gpio movwf gpio ;gpio fixed clrf tmp clrf flags movlw 3 movwf tmp2 ;do it 3 times ; major loop point main: call wait100 ; begin sequence ; send a 11101001 preamble movlw b'10101001' movwf num1 ; send address byte call adrvh movwf num2 call adrvl movwf num3 ; routine to send out 24+1 bits movlw d'25' movwf tmp1 send0a: bsf status,c rlf num3,f rlf num2,f rlf num1,f ;A7 1st bsf gpio,2 ;on, start of bit btfss status,c ;this is correct goto send0b clrwdt ;short nop nop nop bcf gpio,2 nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop decfsz tmp1,f goto send0a goto send0c send0b: clrwdt ;long nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop bcf gpio,2 nop nop nop decfsz tmp1,f goto send0a send0c: call wait100 call wait100 call wait100 call wait100 call wait100 decfsz tmp2,f goto main ; try to turn off 8 times bsf tmp2,3 main1: movlw b'11111000' tris gpio movlw b'11111000' movwf gpio ;signal = LOW call wait100 call wait100 call wait100 movlw b'11111001' movwf gpio ;signal = HI call wait100 call wait100 call wait100 movlw b'11111001' tris gpio movwf gpio ;gpio fixed call wait100 call wait100 call wait100 decfsz tmp2,f goto main ; end ; ; -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads --=====================_77697906==_ Content-Type: text/plain; charset="us-ascii"; format=flowed -------------------------- www.micro-firmware.com PIC Firmware & Hardware 1-866-755-2853 -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads --=====================_77697906==_--