Please help support the site by donating at the link below.https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8ZRU34U47BESW
; Generated by WinDis84, (c) Nigel Goodwin 1998. LIST P=16F84, F=INHX8M include "P16FXX.inc" ORG 0x0000 GOTO Label_0001 ORG 0x0004 MOVWF 0x70 MOVF STATUS , W MOVWF 0x71 BTFSS 0x0C , 01 RETFIE BTFSS 0x20 , 03 GOTO Label_0002 DECFSZ 0x2B , f GOTO Label_0003 MOVLW 0x0A MOVWF 0x2B BCF 0x20 , 03 GOTO Label_0003Label_0002 DECFSZ 0x2B , f GOTO Label_0003 MOVLW 0x0A MOVWF 0x2B BSF 0x20 , 03Label_0003 BTFSC 0x23 , 00 GOTO Label_0004 BSF STATUS , RP0 BSF TRISA , 04 BCF STATUS , RP0 GOTO Label_0005Label_0004 BTFSC 0x20 , 03 BSF PORTA , 04 BTFSS 0x20 , 03 BCF PORTA , 04 BSF STATUS , RP0 BCF TRISA , 04 BCF STATUS , RP0Label_0005 BTFSC 0x23 , 01 GOTO Label_0006 BSF STATUS , RP0 BSF TRISA , 05 BCF STATUS , RP0 GOTO Label_0007Label_0006 BTFSC 0x20 , 03 BSF PORTA , 05 BTFSS 0x20 , 03 BCF PORTA , 05 BSF STATUS , RP0 BCF TRISA , 05 BCF STATUS , RP0Label_0007 BTFSC 0x23 , 00 GOTO Label_0008 BSF STATUS , RP0 BSF TRISA , 00 BCF STATUS , RP0 GOTO Label_0009Label_0008 BTFSS 0x20 , 02 BCF PORTA , 00 BTFSC 0x20 , 02 BSF PORTA , 00 BTFSS 0x20 , 00 GOTO Label_000A DECFSZ 0x21 , f GOTO Label_0009 BCF 0x20 , 00 BSF STATUS , RP0 BSF TRISA , 00 BCF STATUS , RP0 MOVF 0x25 , W MOVWF 0x21 GOTO Label_0009Label_000A DECFSZ 0x22 , f GOTO Label_0009 BSF 0x20 , 00 BSF STATUS , RP0 BCF TRISA , 00 BCF STATUS , RP0 MOVF 0x25 , W MOVWF 0x22Label_0009 BTFSC 0x23 , 01 GOTO Label_000B BSF STATUS , RP0 BSF TRISA , 01 BCF STATUS , RP0 GOTO Label_000CLabel_000B BTFSS 0x20 , 02 BCF PORTA , 01 BTFSC 0x20 , 02 BSF PORTA , 01 BTFSS 0x20 , 01 GOTO Label_000D DECFSZ 0x28 , f GOTO Label_000C BCF 0x20 , 01 BSF STATUS , RP0 BSF TRISA , 01 BCF STATUS , RP0 MOVF 0x25 , W MOVWF 0x28 GOTO Label_000CLabel_000D DECFSZ 0x29 , f GOTO Label_000C BSF 0x20 , 01 BSF STATUS , RP0 BCF TRISA , 01 BCF STATUS , RP0 MOVF 0x25 , W MOVWF 0x29Label_000C BCF 0x0C , 01 MOVF 0x71 , W MOVWF STATUS SWAPF 0x70 , f SWAPF 0x70 , W RETFIE MOVLW 0x40 MOVWF 0x25 RETURNLabel_0015 CLRF 0x27 MOVLW 0x0D MOVWF 0x26Label_000E DECFSZ 0x27 , f GOTO Label_000E DECFSZ 0x26 , f GOTO Label_000E RETURNLabel_0013 BSF STATUS , RP0 MOVLW 0x02 MOVWF 0x1B BSF 0x1C , 00 MOVF 0x1A , W BCF STATUS , RP0 RETURNLabel_0017 BSF STATUS , RP0 MOVWF 0x1A MOVLW 0x02 MOVWF 0x1B BSF 0x1C , 02Label_000F BCF INTCON , GIE BTFSC INTCON , GIE GOTO Label_000F MOVLW 0x55 MOVWF 0x1D MOVLW 0xAA MOVWF 0x1D BSF 0x1C , 01Label_0010 BTFSC 0x1C , 01 GOTO Label_0010 BCF STATUS , RP0 BSF INTCON , GIE RETURNLabel_0001 CLRF PORTA CLRF 0x20 MOVLW 0x07 MOVWF 0x19 BSF STATUS , RP0 MOVLW 0x0F MOVWF TRISA MOVLW 0x51 MOVWF 0x1F MOVLW 0x04 MOVWF 0x15 BCF OPTION_REG, NOT_RBPU BCF STATUS , RP0 MOVLW 0x01 MOVWF 0x1F MOVLW 0x10 MOVWF 0x26Label_0011 DECFSZ 0x26 , f GOTO Label_0011 BSF 0x1F , 01Label_0012 BTFSC 0x1F , 01 GOTO Label_0012 MOVLW 0x40 SUBWF 0x1E , W BTFSC STATUS , C BSF 0x20 , 02 BSF STATUS , RP0 MOVLW 0x0C MOVWF TRISA CLRF 0x1F BCF STATUS , RP0 MOVLW 0x0A MOVWF 0x2B MOVLW 0x3D MOVWF 0x21 MOVWF 0x28 MOVWF 0x22 MOVWF 0x29 CALL Label_0013 MOVWF 0x23 MOVLW 0x01 MOVWF 0x12 BSF STATUS , RP0 MOVLW 0xFA MOVWF 0x12 BSF 0x0C , 01 BCF STATUS , RP0 BSF 0x12 , 02 MOVLW 0xC0 MOVWF INTCONLabel_0018 BTFSC PORTA , 03 GOTO Label_0014 CALL Label_0015 BTFSC PORTA , 03 GOTO Label_0014Label_0016 BTFSS PORTA , 03 GOTO Label_0016 CALL Label_0015 BTFSS PORTA , 03 GOTO Label_0016 MOVLW 0x02 XORWF 0x23 , f CALL Label_0017Label_0014 BTFSC PORTA , 02 GOTO Label_0018 CALL Label_0015 BTFSC PORTA , 02 GOTO Label_0018 MOVLW 0x64 MOVWF 0x24Label_001A CALL Label_0015 BTFSC PORTA , 02 GOTO Label_0019 DECFSZ 0x24 , f GOTO Label_001A MOVLW 0x40 ADDWF 0x23 , f MOVLW 0x3D MOVWF 0x25 BCF 0x23 , 00 MOVLW 0x0A MOVWF 0x2CLabel_001B CALL Label_0015 DECFSZ 0x2C , f GOTO Label_001B BSF 0x23 , 00 BSF 0x20 , 04 GOTO Label_0019Label_0019 BTFSS PORTA , 02 GOTO Label_0019 CALL Label_0015 BTFSS PORTA , 03 GOTO Label_0019 BTFSC 0x20 , 04 GOTO Label_001C MOVLW 0x01 XORWF 0x23 , fLabel_001C BCF 0x20 , 04 CALL Label_0017 GOTO Label_0018 ORG 0x2000 DATA 0x0F DATA 0x0F DATA 0x0F DATA 0x0F ORG 0x2007 DATA 0x04 ORG 0x2100 DATA 0x00 DATA 0x00 DATA 0x00 DATA 0x00 DATA 0x00 DATA 0x00 DATA 0x00 DATA 0x07
;***** VARIABLE DEFINITIONS******************w_temp EQU 0x70 ; variable used for context saving status_temp EQU 0x71 ; variable used for context savingFLAGS EQU 0x20 ;software state registerPULSER EQU 0x21 ;pulse on counterDWELLTIMER EQU 0x22 ;pulse off counterSTATE EQU 0x23 ;programmed stateBUTTONHOLD EQU 0x24FREQR EQU 0x25 ;frequency valueTEMP1 EQU 0x26TEMP2 EQU 0x27PULSEL EQU 0x28DWELLTIMEL EQU 0x29TEMP5 EQU 0x2ALEDBLINK EQU 0x2BTEMP3 EQU 0x2C;*******bits in FLAGS register***********PULSEONR equ 0PULSEONL equ 1TRIGOUT equ 2LEDHI equ 3STATECHANGE equ 4;*******bits in STATE register***********RIGHTACTIVE equ 0LEFTACTIVE equ 1;*********GPIO pin names*****************LEDL equ 5LEDR equ 4BUTTONR equ 2BUTTONL equ 3TRIGGERR equ 0TRIGGERL equ 1;**********Speed settings: change these to change speed (0x05-0xFF)FIRERATE1 equ 0x2FFIRERATE2 equ 0x16FIRERATE3 equ 0x12FIRERATE4 equ 0x0F;********************************************************************** ORG 0x000 ; processor reset vector goto main ; go to beginning of program ORG 0x004 ; interrupt vector location movwf w_temp ; save off current W register contents movf STATUS,w ; move status register into W register movwf status_temp ; save off contents of STATUS register ;Take a good note here. OSC is left at default 4MHz. ; We are running at 1MHz instruction cycle, or 1 micro second ;Timer 2 is prescaled 1:4 and compared (PR2) to 250. ; we now have hardware interupt that falls every 1ms exactly ;within limitation of osctune. Main code is inconsequential. ;PULSE and DWELL values control the signals precisely. ;All pulse logic is switched within the few microseconds to ;service the interupt routine. DO NOT modify the ISR ;with any kind of 'wait' or 'loop'. If you want to trigger ; timed events do so by setting an open FLAG bit and have the ;event done in the main loop. btfss PIR1, TMR2IF ;timer 2 int happened retfie;**************** LED blinking ********************************************* ;Our main routine will turn the flag bit ;LEDON on or off. The 10ms pulse is a duty cycle ;for the code to work with both CG and ;matrix controllers. BlinkLed btfss FLAGS, LEDHI goto LedLow decfsz LEDBLINK, f ;if pulse is active, count down 10ms goto RightLED movlw 0x0A movwf LEDBLINK bcf FLAGS, LEDHI ;10ms done, turn off LEDHI bit goto RightLEDLedLow decfsz LEDBLINK, f ;LEDLO time, count down 10ms goto RightLED movlw 0x0A movwf LEDBLINK bsf FLAGS, LEDHI ;10ms done, turn LEDHI bit onRightLED btfsc STATE, RIGHTACTIVE ;is RF on? goto OutputRightLED bsf STATUS, RP0 ;bank 1 bsf TRISIO, LEDR ;tristate LED bcf STATUS, RP0 ;bank 0 goto LeftLEDOutputRightLED btfsc FLAGS, LEDHI ;if ledhi true, bsf GPIO, LEDR ;turn output hi btfss FLAGS, LEDHI ;if ledhi flase, bcf GPIO, LEDR ;turn led output lo bsf STATUS, RP0 ;bank 1 bcf TRISIO, LEDR ;turn output on bcf STATUS, RP0 ;bank 0LeftLED btfsc STATE, LEFTACTIVE ;is RF on? goto OutputleftLED bsf STATUS, RP0 ;bank 1 bsf TRISIO, LEDL ;tristate LED bcf STATUS, RP0 ;bank 0 goto RightTriggerOutputleftLED btfsc FLAGS, LEDHI ;if ledhi true, bsf GPIO, LEDL ;turn output hi btfss FLAGS, LEDHI ;if ledhi flase, bcf GPIO, LEDL ;turn led output lo bsf STATUS, RP0 ;bank 1 bcf TRISIO, LEDL ;turn output on bcf STATUS, RP0 ;bank 0;**************** Right trigger logic*************************************** RightTrigger btfsc STATE, RIGHTACTIVE ;is RF on? goto ActiveR bsf STATUS, RP0 ;bank 1 bsf TRISIO, TRIGGERR ;output off bcf STATUS, RP0 ;bank 0 goto LeftTriggerActiveR btfss FLAGS, TRIGOUT ;controllertype bcf GPIO, TRIGGERR ;determines btfsc FLAGS, TRIGOUT ;output state bsf GPIO, TRIGGERR btfss FLAGS, PULSEONR ;is pulse active? goto OffstateR decfsz PULSER, f ;if pulse is active, count down 10ms goto LeftTrigger bcf FLAGS, PULSEONR ;10ms is over, clear flags and bsf STATUS, RP0 ;bank 1 bsf TRISIO, TRIGGERR ;tristate output bcf STATUS, RP0 ;bank 0 movf FREQR, w ;and reset pulse time. movwf PULSER goto LeftTriggerOffstateR decfsz DWELLTIMER, f ;count down dwell time to next pulse goto LeftTrigger bsf FLAGS, PULSEONR ;if dwell is done turn on outputs bsf STATUS, RP0 ;bank 1 bcf TRISIO, TRIGGERR ;and reset pulse time bcf STATUS, RP0 ;bank 0 movf FREQR, w ;from frequency value movwf DWELLTIMERLeftTrigger btfsc STATE, LEFTACTIVE ;is RF on? goto ActiveL bsf STATUS, RP0 ;bank 1 bsf TRISIO, TRIGGERL ;output off bcf STATUS, RP0 ;bank 0 goto EndInteruptActiveL btfss FLAGS, TRIGOUT ;controllertype bcf GPIO, TRIGGERL ;determines btfsc FLAGS, TRIGOUT ;output state bsf GPIO, TRIGGERL btfss FLAGS, PULSEONL ;is pulse active? goto OffstateL decfsz PULSEL, f ;if pulse is active, count down 10ms goto EndInterupt bcf FLAGS, PULSEONL ;10ms is over, clear flags and bsf STATUS, RP0 ;bank 1 bsf TRISIO, TRIGGERL ;tristate output bcf STATUS, RP0 ;bank 0 movf FREQR, w ;and reset pulse time. movwf PULSEL goto EndInteruptOffstateL decfsz DWELLTIMEL, f ;count down dwell time to next pulse goto EndInterupt bsf FLAGS, PULSEONL ;if dwell is done turn on outputs bsf STATUS, RP0 ;bank 1 bcf TRISIO, TRIGGERL ;and reset pulse time bcf STATUS, RP0 ;bank 0 movf FREQR, w ;from frequency value movwf DWELLTIMELEndInterupt bcf PIR1, TMR2IF movf status_temp,w ; retrieve copy of STATUS register movwf STATUS ; restore pre-isr STATUS register contents swapf w_temp,f swapf w_temp,w ; restore pre-isr W register contents retfie ; return from interrupt;*************************************SUBROUTINES**********************************Wait10ms clrf TEMP2 movlw 0x0D movwf TEMP1 ;rough 10ms timer for button debounce.Loop1 decfsz TEMP2, f ;count down 256*3=768 cycles goto Loop1 decfsz TEMP1, f ;count down 768*13=9986 cycles goto Loop1 return ;*************************************************************ReadEE bsf STATUS , RP0 ;Bank1 movlw 0x02 movwf EEADR bsf EECON1 , RD ;start read movf EEDAT , W bcf STATUS , RP0 ;Bank0 return ;*************************************************************WriteEE bsf STATUS , RP0 movwf EEDAT movlw 0x02 movwf EEADR bsf EECON1,WREN ;Enable write bcf INTCON, GIE ;Disable INTs btfsc INTCON, GIE ;See AN576 goto $-2 movlw 0x55 ;Unlock write movwf EECON2 movlw 0xAA movwf EECON2 bsf EECON1, WR ;Start the writeWaitForEEWrite btfsc EECON1, WR ;wait for hardware to clear (done writing) goto WaitForEEWrite bcf STATUS , RP0 ;Bank0 bsf INTCON, GIE ;Enable INTS return;**********************************************************************************;**********************************************************************************;**********************************************************************************main clrf GPIO clrf FLAGS ;clear outputs and code status register movlw 0x07 movwf CMCON0 ;comparators off bsf STATUS, RP0 ;bank 1 movlw 0x0F ;start with 0-3 inputs (ADC read) movwf TRISIO ;pin 0 & 1 & 5 out, all other inputs movlw 0x51 ;Fosc/16, pin 0 analog movwf ANSEL ;Right trigger is analog input movlw 0x04 movwf WPU ;enable week pullups bcf OPTION_REG, 7 ;enable all week pullups bcf STATUS, RP0 ;bank 0 movlw 0x01 ;Left just, Vdd, channel 0 movwf ADCON0 ;module on. movlw 0x10 movwf TEMP1Wait4ADC decfsz TEMP1, f goto Wait4ADC ;acquisition time bsf ADCON0, 1 ;start ADC btfsc ADCON0, 1 goto $-1 ;wait for conversion to be done movlw 0x40 ;about 0.5V from 2V ref subwf ADRESH, w ;if f > W, C=1 btfsc STATUS, C ;ie- if trigger > 0.5V, then matrix bsf FLAGS, TRIGOUT ;matrix config sources (output high) bsf STATUS, RP0 ;bank 1 movlw 0x0C ;restore pin IO movwf TRISIO clrf ANSEL ;all digital now bcf STATUS, RP0 ;bank 0 movlw 0x0A ;start with 10ms pulse width movwf LEDBLINK ;for the LEDs movlw FIRERATE1 ;this will get overwritten, movwf PULSER ; but start with a default value movwf PULSEL movwf DWELLTIMER movwf DWELLTIMEL call ReadEE ;get state value movwf STATE movlw 0x01 movwf T2CON ;timer 2, prescale 1:4, no postscale bsf STATUS, RP0 ;bank 1 movlw 0xFA movwf PR2 ;setup 1ms hardware interupt bsf PIE1, TMR2IE ;enable timer2 interupt bcf STATUS, RP0 ;bank 0 bsf T2CON, TMR2ON ;turn on timer2 movlw 0xC0 movwf INTCON ;turn on interupts globally goto InitState ;get first firerate value;******MAIN LOOP***************StartTestLeft btfsc GPIO, BUTTONL goto TestRight ;Test for left button press call Wait10ms btfsc GPIO, BUTTONL ;button is down for 10ms goto TestRightReleaseLeft btfss GPIO, BUTTONL ;wait for button release goto ReleaseLeft call Wait10ms btfss GPIO, BUTTONL ;wait for button release goto ReleaseLeft movlw 0x02 xorwf STATE, f ;toggle left trigger call WriteEE ;store stateTestRight btfsc GPIO, BUTTONR goto Start; goto DisplayState ;Test for right button press call Wait10ms btfsc GPIO, BUTTONR ;button is down for min 10ms goto Start; goto DisplayState movlw 0xC8 movwf BUTTONHOLD ;setup for 2 second holdFirst2seconds call Wait10ms btfsc GPIO, BUTTONR ;button is down for more than 10ms goto ReleaseRight decfsz BUTTONHOLD, f goto First2seconds movlw 0xC8 movwf BUTTONHOLD ;setup for 2 second holdSecond2seconds call Wait10ms btfsc GPIO, BUTTONR goto ReleaseRight decfsz BUTTONHOLD, f goto Second2seconds ;button down for 4 seconds, change firerate NextState movlw 0x40 addwf STATE, f ;change firerate stateInitState ;begin test for btfsc STATE, 7 ;state 1 or 2 goto State3 btfsc STATE, 6 goto State2State1 movlw FIRERATE1 ;state 1 movwf FREQR bcf STATE, RIGHTACTIVE ;led off movlw 0x0A movwf TEMP3Loop01 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop01 bsf STATE, RIGHTACTIVE ;led on bsf FLAGS, STATECHANGE ;notify a state change goto ReleaseRightState2 movlw FIRERATE2 ;state 2 movwf FREQR bcf STATE, RIGHTACTIVE ;blink twice, led off movlw 0x0A movwf TEMP3Loop02 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop02 bsf STATE, RIGHTACTIVE ;led on movlw 0x0A movwf TEMP3Loop03 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop03 bcf STATE, RIGHTACTIVE ;led off movlw 0x0A movwf TEMP3Loop04 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop04 bsf STATE, RIGHTACTIVE ;led on bsf FLAGS, STATECHANGE ;notify a state change goto ReleaseRightState3 btfsc STATE, 6 goto State4 movlw FIRERATE3 ;state 3 movwf FREQR bcf STATE, RIGHTACTIVE ;blink 3 times, led off movlw 0x0A movwf TEMP3Loop05 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop05 bsf STATE, RIGHTACTIVE ;led on movlw 0x0A movwf TEMP3Loop06 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop06 bcf STATE, RIGHTACTIVE ;led off movlw 0x0A movwf TEMP3Loop07 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop07 bsf STATE, RIGHTACTIVE ;led on movlw 0x0A movwf TEMP3Loop08 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop08 bcf STATE, RIGHTACTIVE ;led off movlw 0x0A movwf TEMP3Loop09 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop09 bsf STATE, RIGHTACTIVE ;led on bsf FLAGS, STATECHANGE ;notify a state change goto ReleaseRightState4 movlw FIRERATE4 ;state 4, 22ms cycle movwf FREQR bcf STATE, RIGHTACTIVE ;blink 4 times, led off movlw 0x0A movwf TEMP3Loop10 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop10 bsf STATE, RIGHTACTIVE ;led on movlw 0x0A movwf TEMP3Loop11 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop11 bcf STATE, RIGHTACTIVE ;led off movlw 0x0A movwf TEMP3Loop12 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop12 bsf STATE, RIGHTACTIVE ;led on movlw 0x0A movwf TEMP3Loop13 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop13 bcf STATE, RIGHTACTIVE ;led off movlw 0x0A movwf TEMP3Loop14 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop14 bsf STATE, RIGHTACTIVE ;led on movlw 0x0A movwf TEMP3Loop15 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop15 bcf STATE, RIGHTACTIVE ;led off movlw 0x0A movwf TEMP3Loop16 call Wait10ms ;100 ms decfsz TEMP3, f goto Loop16 bsf STATE, RIGHTACTIVE ;led on bsf FLAGS, STATECHANGE ;notify a state changeReleaseRight btfss GPIO, BUTTONR ;wait for button release goto ReleaseRight call Wait10ms btfss GPIO, BUTTONL ;wait for button release goto ReleaseRight btfsc FLAGS, STATECHANGE ;test for button tap or state change goto Continue01 movlw 0x01 xorwf STATE, f ;toggle left trigger if button tapContinue01 bcf FLAGS, STATECHANGE call WriteEE ;store state goto Start ; initialize eeprom locations ORG 0x2100 DE 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07 END ; directive 'end of program'
I got these so called hex Codes off of :censored
No Freek. I like u.