; Code for W5ALT keyer list p=16F84A __config 0x3FF1 ; ; Register definitions PCL equ 0x02 ; PCL register STATUS equ 0x03 ; STATUS register RP0 equ 0x5 ; Bank switch bit CARRY equ 0x0 ; C bit EEDATA equ 0x08 ; EEPROM Data Address EEADR equ 0x09 ; EEPROM Register Address EECON1 equ 0x08 ; EEPROM Data Address EECON2 equ 0x09 ; EEPROM Register Address RD equ 0x0 ; EEPROM Read bit WR equ 0x1 ; EEPROM Write bit WREN equ 0x2 ; EEPROM Write enable bit portb equ 0x06 ; adr of portb ; ; PORTB pin mapping led equ 0x00 ; RB0 = bit for LED spkr equ 0x01 ; RB1 = bit for spkr keyout equ 0x02 ; RB2 = bit for key output ditin equ 0x03 ; RB3 = bit for dit paddle dahin equ 0x04 ; RB4 = bit for dah paddle cmdin equ 0x05 ; RB5 = bit for cmd mode ; ; Memory register numbers CNT1 equ 0x0C CNT2 equ 0X0D DLYREG equ 0x10 ; 1 ms delay count DITREG equ 0x11 ; dit length count DAHREG equ 0x12 ; dah length count ; ; EEPROM Register numbers EEDITLEN equ 0x02 ; ; Assorted constants ditlen equ 0x30 ; dahlen equ 3*ditlen dlylen equ 0xDF ; org 0x000 goto BEGIN org 0x004 BEGIN movlw dlylen movwf DLYREG ; movlw ditlen call GET_DAT movwf DITREG bcf DITREG, 7 bcf DITREG, 6 movf DITREG, W movwf DAHREG addwf DAHREG, F addwf DAHREG, F ; RESTART movlw 0x00 ; enable pull up on portb inputs option movlw 0xF8 ; define RB0, RB1, RB2 as output tris portb ; bcf portb, keyout bcf portb, led call DIT call DAH ; Beep at startup call DIT call SPC ; ; ; The basic algorithm for the keyer is: ; Check dit paddle - send dit if pressed ; Check dah paddle - send dah if pressed ; Check for command mode ; Cycle ; START btfss portb, ditin ; check dit paddle call DIT ; send dit if pressed btfss portb, dahin ; check dah paddle call DAH ; send dah if pressed btfsc portb, cmdin ; check speed adjust goto START ; recycle if no adjust ; ; enter command mode call SPC call DIT call DIT call DIT call SPC call SPC DO_SPD btfsc portb, cmdin goto END_SPD ; speed adjustment call DIT call DAH btfsc portb, ditin ; check dit paddle goto ADJ_SLO ; movlw 4 ; go faster subwf DITREG, F ; decrease the dit length bcf DITREG, 7 bcf DITREG, 6 movf DITREG, W movwf DAHREG addwf DAHREG, F addwf DAHREG, F goto DO_SPD ADJ_SLO btfsc portb, dahin ; check dah paddle goto DO_SPD ; movlw 4 ; go slower addwf DITREG, F ; increase the dit length bcf DITREG, 6 movf DITREG, W movwf DAHREG addwf DAHREG, F addwf DAHREG, F goto DO_SPD ; end of speed adjustment END_SPD call SAV_DAT goto RESTART ; ; This routine saves speed data to EEPROM SAV_DAT movf DITREG, W movwf EEDATA movlw EEDITLEN movwf EEADR bsf STATUS, RP0 bsf EECON1, WREN movlw 0x55 movwf EECON2 movlw 0xAA movwf EECON2 bsf EECON1, WR bcf EECON1, WREN bcf STATUS, RP0 return ; ; This routine reads speed data from EEPROM GET_DAT bcf STATUS, RP0 movlw EEDITLEN movwf EEADR bsf STATUS, RP0 bsf EECON1, RD bcf STATUS, RP0 movf EEDATA, W movwf DITREG return ; ; This routine makes a dit and space DIT movf DITREG, W movwf CNT2 bsf portb, led bsf portb, keyout DIT1 decfsz CNT2, F goto DIT2 goto DIT3 DIT2 bsf portb, spkr call DELAY bcf portb, spkr call DELAY goto DIT1 DIT3 movf DITREG, W movwf CNT2 DIT4 decfsz CNT2, F goto DIT5 return DIT5 bcf portb, led bcf portb, keyout bcf portb, spkr call DELAY bcf portb, spkr call DELAY goto DIT4 ; ; This routine makes a dah and space DAH movf DAHREG, W movwf CNT2 bsf portb,led bsf portb, keyout DAH1 decfsz CNT2, F goto DAH2 goto DAH3 DAH2 bsf portb, spkr call DELAY bcf portb, spkr call DELAY goto DAH1 DAH3 movf DITREG, W movwf CNT2 DAH4 decfsz CNT2, F goto DAH5 return DAH5 bcf portb, led bcf portb, keyout bcf portb, spkr call DELAY bcf portb, spkr call DELAY goto DAH4 ; ; This routine makes a letter space SPC movf DAHREG, W movwf CNT2 bcf portb, led bcf portb, keyout SPC1 decfsz CNT2, F goto SPC2 goto SPC3 SPC2 bcf portb, spkr call DELAY bcf portb, spkr call DELAY goto SPC1 SPC3 movf DITREG, W movwf CNT2 SPC4 decfsz CNT2, F goto SPC5 return SPC5 bcf portb, spkr call DELAY bcf portb, spkr call DELAY goto SPC4 ; DELAY movf DLYREG, W ; delay for 1 msec movwf CNT1 DELAY1 decfsz CNT1, F goto DELAY1 return ; end ;