At 11:09 AM 6/3/96 +0100, you wrote: >Wynn Rostek wrote: > >> I can send code if anyone is really interested. > >If, like Wynn, anyone has some PIC-related code they want to share, >please feel free to send me a copy via e-mail (as a MIME enclosure or >UUencoded) and I'll make it available on my FTP area: > >ftp://ftp.mcc.ac.uk/pub/micro-controllers/PIC > >Please warn me if you are going to send large (> few hundred K) files. > >David >-- >david.tait@man.ac.uk > > ; FILE: bunny.asm ; ; 11/30/95 Started work on this file ...WAR... ; ; Simple bunny controller for 16C84 ; Assemble with MPASM /e /l /rDEC /p16C84 bunny.asm include "p16cxx.inc" include "p16cxxd.inc" ; Set config fuses to 0x1a ; ; HS oscillator (6 MHz Xtal) ; Watchdog timer disabled ; Power-up timer enabled ; Code protection off ; For code at 10 WPM, each unit is 120 milliseconds long. ; This is 90 cycles of a 750 Hz tone. ; our variables cnt equ 0x0c cyc equ 0x0d units equ 0x0e tmp equ 0x0f org 0x000 ; The main line code starts here ; First we do all required initialization Start ; Set port A as output bsf STATUS,RP0 ;Bank 1 movlw 0 movwf TRISA ; Enable port B pullups bcf OPTION_REG,NOT_RBPU ; Switch back to bank 0 bcf STATUS,RP0 ;Bank 0 ; Ready for main loop Top bsf RA1 ;key the transmitter movlw 41 ;wait 5 seconds movwf units call dlunit call id ;send ID movlw 131 ;wait 15.75 seconds movwf units call dlunit call id ;send ID movlw 41 ;wait 5 seconds movwf units call dlunit bcf RA1 ;unkey the transmitter movlw 250 ;wait 60 seconds movwf units call dlunit movlw 250 movwf units call dlunit goto Top ; Send an ID message id call dash call dot call dot call spc call dot call ps call dot call dash call dash call spc call dash call dot call dot call dot call spc call dot call dot call dot call dot call dash call spc call dash call dash call dot call dot call spc call dot call dot call dash call spc call dash call dot call dash call dash call ps call dot call dot call dash call dot call spc call dash call dash call dash call spc call dash call dot call dot call dash call ps return ; Send a dot dot movlw 1 movwf units call tnunit movlw 1 movwf units call dlunit return ;Send a dash dash movlw 3 movwf units call tnunit movlw 1 movwf units call dlunit return ;Finish a space spc movlw 2 movwf units call dlunit return ;Finish a pause ps movlw 6 movwf units call dlunit return ; Delay units * 90 cycles of 750 Hz tone dlunit movlw 90 movwf cyc dlhi nop bcf RA0 ;set tone bit low call haf ;wait a bit nop ;waste 8 cycles for symmetry movlw 2 movwf tmp dlmid decfsz tmp,1 goto dlmid bcf RA0 ;set tone bit low call haf ;wait a bit decfsz cyc,1 ;one less cycle to send goto dlpad ;do another cycle decfsz units,1 ;Another unit done goto dlunit return dlpad nop ;4 cycles for padding nop goto dlhi ; Send units * 90 cycles of 750 Hz tone tnunit movlw 90 movwf cyc tnhi nop bsf RA0 ;set tone bit high call haf ;wait a bit nop ;waste 8 cycles for symmetry movlw 2 movwf tmp tnmid decfsz tmp,1 goto tnmid bcf RA0 ;set tone bit low call haf ;wait a bit decfsz cyc,1 ;one less cycle to send goto tnpad ;do another cycle decfsz units,1 ;Another unit done goto tnunit return tnpad nop ;4 cycles for padding nop goto tnhi ; delay for half a cycle of 750 Hz ; A 750 HZ tone is 1.333333 milliseconds ; in duration. This means each half cycle ; of the tone is 666.6666 microseconds. ; Since I'm using a 6.0 MHz Xtal, this ; is 1000 CPU cycles per tone half cycle. ; Since the routine that calls this to generate ; the tone takes 11 CPU cycles per Tone half ; cycle, we need to burn up 989 CPU cycles ; in this routine. ; This routine takes 13 + ((K -1) * 4) cycles ; where K is the argument for the movlw ; instruction. haf nop nop nop movlw 245 movwf cnt luphaf nop decfsz cnt,1 goto luphaf goto lupxt lupxt nop return end ; FILE: ddf1.asm ; Ducky direction finder controller for 16C84 ; ; 12/07/95 Started work on this file ...WAR... ; ; Assemble with MPASM /e /l /rDEC /p16C84 ddf1.asm ; RA0/RA1 are used to drive antenna switching. ; RA2/RA3 are used to drive phase indicators. ; RA4 is the audio input. include "p16c84.inc" ; Set config fuses to 0x1a ; ; HS oscillator (6 MHz Xtal) ; Watchdog timer disabled ; Power-up timer enabled ; Code protection off ; with a 6 Mhz Xtal, each cycle is 66.667 usec long ; for a basic 400 Hz tone, the cycle is 2.5 msec. ; This means a half cycle is 1.25 msec, or 1875 CPU cycles. ; our variables cnt equ 0x0c tmp equ 0x0d org 0x000 ; The main line code starts here ; First we do all required initialization Start ; Set low nybble of port A as output bsf STATUS,RP0 ;Bank 1 movlw 0xf0 movwf TRISA ; Switch back to bank 0 bcf STATUS,RP0 ;Bank 0 ; Ready for main loop Top bsf PORTA,0 ;Turn right antenna on bcf PORTA,1 ;Turn left antenna off bcf PORTA,2 btfsc PORTA,4 bsf PORTA,2 call haf ;wait a bit nop ;Burn 2 cycles for symmetry nop bsf PORTA,1 ;Turn left antenna on bcf PORTA,0 ;Turn right antenna off bcf PORTA,3 btfsc PORTA,4 bsf PORTA,3 call haf ;wait a bit goto Top ; delay for half a cycle of 400 Hz. ; A 400 HZ tone is 2.5 milliseconds ; in duration. This means each half cycle ; of the tone is 1.25 milliseconds. ; Since I'm using a 6.0 MHz Xtal, this ; is 1875 CPU cycles per tone half cycle. ; Since the routine that calls this to generate ; the tone takes 9 CPU cycles per Tone half ; cycle, we need to burn up 1866 CPU cycles ; in this routine. ; This routine takes 10 + ((K - 1) * 16) cycles ; where K is the argument for the movlw ; instruction. haf ; we need an extra 4 cycles of padding ; to get the time to come out right nop nop nop nop ; now we run the main loop 116 times movlw 117 movwf cnt hafl decfsz cnt,1 goto dowt return dowt call dly goto hafl ; Burn up 9 cycles. dly movlw 2 movwf tmp dlp decfsz tmp,1 goto dlp return end Wynn Rostek war@palmnet.net wynn@pitcairn.ksc.nasa.gov wynn.rostek@ksc.nasa.gov Other Email addresses available if you really need 'em...