Author Topic: rapid fire code help plS!!!!  (Read 2058 times)

Offline hectorm

  • Guppy
  • *
  • Posts: 5
  • Post quality +0/-0
  • Gender: Male
  • Acidmods User
rapid fire code help plS!!!!
« on: August 04, 2012, 04:07:44 AM »
 :beg: i done adding more mod to bmux but now i have problems with leds flashing  :beg:b
« Last Edit: August 06, 2012, 11:42:27 AM by hectorm »

Offline Layman

  • Chief squatting Hard
  • *
  • Posts: 18
  • Post quality +1/-0
  • Gender: Male
  • Acidmods User
Re: rapid fire code help plS!!!!
« Reply #1 on: August 19, 2012, 01:37:04 PM »
what did you change, i may be able to help

Offline hectorm

  • Guppy
  • *
  • Posts: 5
  • Post quality +0/-0
  • Gender: Male
  • Acidmods User
Re: rapid fire code help plS!!!!
« Reply #2 on: August 21, 2012, 02:00:05 AM »
this is the code i change check and let me knw what i do wrong :
;*****   FLASH COUNTER TIME *****
FLASHCNT   EQU   .45

;*****   FIRERATES *****
FIRERATE1   equ   .133      ;7.5 sps
FIRERATE2   equ   .120      ;8.33 sps
FIRERATE3   equ   .88          ;11.35 sps
FIRERATE4   equ   .60          ;16.67 sps
FIRERATE5   equ   .40          ;25 sps
;to get desired speed divide 1000 by your desired sps then enter
;it here and recompile and reprogram the code


;*****   FLAGS   *****
OFF      EQU      0      ;set equ rf off
DBN      EQU      1
DBN2   EQU      2

;*****   GPIO   *****
BUTTON   EQU      4
LED      EQU      2
RCOM   EQU      1

;*****   FLASH   *****
ON1              EQU              0
OFF1   EQU              1
ON2              EQU              2
OFF2   EQU              3
ON3              EQU              4
OFF3   EQU              5
ON4              EQU              6
OFF4   EQU              7
ON5             EQU             8
OFF5    EQU             9

;**********************************************************************
   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

   btfsc   FLAGS,OFF         ;skip if mode 0
   goto   Offstate
   bcf      STATUS, RP0         ;bank 0
   btfss   SHADOW, 1
   goto   DwellRF
   nop
   decfsz   PULSE1, f
   goto   EndInterupt
Clears
   bcf      SHADOW, 1
   movfw   FREQ
   movwf   PULSE1
   goto   EndInterupt2

DwellRF
   decfsz   DWELL1, f
   goto   EndInterupt
   bsf      SHADOW, 1
   movfw   FREQ
   movwf   DWELL1   
   goto   EndInterupt2
   
Offstate
   nop
   nop
   nop
   nop
   goto   Clears

EndInterupt
   nop
   nop
   nop
   nop
EndInterupt2
   nop
   nop
   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****************************************

Wait500us
   movlw   0x07
   movwf   TEMP01
   movlw   0x12
   movwf   TEMP02
   
Loop01
   decfsz   TEMP01, f         ;20usec loop
   goto   Loop01

   movlw   0x07
   movwf   TEMP01
   decfsz   TEMP02, f
   goto   Loop01         ;25usec loop
   return               ;really 478us

FLASHOFF1
   bcf      GPIO,LED
   decfsz   COUNTER01
   return
   bcf      FLASH,OFF1
   bsf      FLASH,ON1
   return

FLASHON1
   bsf      GPIO,LED
   bcf      FLASH,OFF1
   movlw   FLASHCNT
   movwf   COUNTER01
   return

FLASHOFF2
   bcf      GPIO,LED
   decfsz   COUNTER01
   return
   movlw   FLASHCNT
   movwf   COUNTER01
   bcf      FLASH,OFF2
   bsf      FLASH,ON2
   return

FLASHON2
   bsf      GPIO,LED
   decfsz   COUNTER01
   return
   movlw   FLASHCNT
   movwf   COUNTER01
   bcf      FLASH,ON2
   bsf      FLASH,OFF1
   return

FLASHOFF3
   bcf      GPIO,LED
   decfsz   COUNTER01
   return
   movlw   FLASHCNT
   movwf   COUNTER01
   bcf      FLASH,OFF3
   bsf      FLASH,ON3
   return

FLASHON3
   bsf      GPIO,LED
   decfsz   COUNTER01
   return
   movlw   FLASHCNT
   movwf   COUNTER01
   bcf      FLASH,ON3
   bsf      FLASH,OFF2
   return

FLASHOFF4
   bcf      GPIO,LED
   decfsz   COUNTER01
   return
   movlw   FLASHCNT
   movwf   COUNTER01
   bcf      FLASH,OFF4
   bsf      FLASH,ON4
   return

FLASHON4
   bsf      GPIO,LED
   decfsz   COUNTER01
   return
   movlw   FLASHCNT
   movwf   COUNTER01
   bcf      FLASH,ON4
   bsf      FLASH,OFF3
   return

FLASHOFF5
   bcf      GPIO,LED
   decfsz   COUNTER01
   return
   movlw   FLASHCNT
   movwf   COUNTER01
   bcf      FLASH,OFF5
   bsf      FLASH,ON5
   return

FLASHON5
   bsf      GPIO,LED
   decfsz   COUNTER01
   return
   movlw   FLASHCNT
   movwf   COUNTER01
   bcf      FLASH,ON5
   bsf      FLASH,OFF4
   return

Waitup
   btfss   GPIO,BUTTON
   return

   movlw   0x40
   addwf   STATER, f         ;cyclic change in state manipulates
                        ;last 2 bits in STATER.
    movf    STATER, w

   btfsc   STATER, 7         ;state 1 or 2
   goto   Continue01
   btfsc   STATER, 6
   goto    Continue02
   btfsc   STATER, 5
   goto   State2
State1      ;OFF
   clrf   FLASH
   bcf      GPIO,LED
   bsf      FLAGS,OFF
   goto   Startover

State2
   movlw   FIRERATE1
   movwf   FREQ
   clrf   FLASH
   bsf      GPIO,LED
   bcf      FLAGS,OFF
   goto   Startover

Continue01
   btfss   STATER, 7      ;state 3 or state 4
   goto   State4
State3
   movlw   FIRERATE3
   movwf   FREQ
   clrf   FLASH
   bsf      FLASH, OFF3
   bcf      FLAGS,OFF
   goto   Startover

State4
   movlw   FIRERATE2
   movwf   FREQ
   clrf   FLASH
   bsf      FLASH, OFF2
   bcf      FLAGS,OFF
   goto   Startover
   
Continue02
   btfss   STATER, 6      ;state 5 or state 6
   goto   State6
State5
   movlw   FIRERATE5
   movwf   FREQ
   clrf   FLASH
   bsf      FLASH, OFF5
   bcf      FLAGS,OFF
   goto   Startover

State6
   movlw   FIRERATE4
   movwf   FREQ
   clrf   FLASH
   bsf      FLASH, OFF4
   bcf      FLAGS,OFF
   goto   Startover

Startover
   bcf      FLAGS,DBN
   return

   

;***********************************************************************
;***********************************************************************
;***********************************************************************

main
   bsf      STATUS, RP0         ;bank 1
   movlw   b'111011'         ;all ports inputs
   movwf   TRISIO
   movlw   0x02         ;GP1 analog
   movwf   ANSEL
   movlw   b'00010000'
   movwf   WPU               ;enable week pullups
   bcf      OPTION_REG, 7      ;enable all week pullups
   movlw   0x8F         ;Vref on, highest setting
   movwf   VRCON
   bcf      STATUS, RP0         ;bank 0
   movlw   0x04
   movwf   CMCON0            ;comparator on
   bsf      GPIO, 1         ;latch output high
   bcf      GPIO, LED
   
   clrf   FLASH
   clrf   SHADOW
   clrf   SHADOW2
   clrf   FLAGS
   clrf   STATER
   bsf      FLAGS,OFF

   movlw   FLASHCNT
   movwf   COUNTER01   

   movlw   0x01
   movwf   T2CON            ;timer 2, prescale 1:4, no postscale
   bsf      STATUS, RP0         ;bank 1
   movlw   0x7C            
   movwf   PR2               ;setup 500us hardware interupt
   bsf      PIE1, TMR2IE      ;enable timer2 interupt
   bcf      STATUS, RP0         ;bank 0
   bsf      T2CON, TMR2ON      ;turn on timer2
   movlw   0xC0
   movwf   INTCON

Start
   btfss   CMCON0, COUT
   goto   Start         ;wait for falling edge of R2

   call   Wait500us      ;skip over R2
   movf   SHADOW, w
   movwf   SHADOW2
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop

   bcf      INTCON, GIE
   movlw   0x07
   movwf   CMCON0         ;comp off
   bsf      STATUS, RP0         ;bank 1
   bcf      ANSEL, 1      ;digital
   movf   SHADOW2, w
   xorwf   TRISIO,f      ;output
   bcf      STATUS, RP0         ;bank 0
   bsf      INTCON, GIE

   call   Wait500us      ;wait out R1

   
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop                  ;maintain 500 usec
   bcf      INTCON, GIE
   bsf      STATUS, RP0         ;bank 1
   movf   SHADOW2, w
   xorwf   TRISIO, f      
   bsf      ANSEL, 1      ;analog
   bcf      STATUS, RP0         ;bank 0
   bsf      INTCON, GIE

   call   Wait500us      ;wait out triangle
   
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   call   Wait500us      ;wait out circle
   
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   call   Wait500us      ;wait out X
   
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   call   Wait500us      ;wait out square
   
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   nop
   call   Wait500us      ;wait some more

   bsf      STATUS, RP0         ;bank 1
   bsf      TRISIO, 1         ;force input
   bcf      STATUS, RP0         ;bank 0

   btfsc   FLASH, ON1         ;Handling of LED flashing
   call   FLASHON1

   btfsc   FLASH, OFF1
   call   FLASHOFF1

   btfsc   FLASH, ON2
   call   FLASHON2

   btfsc   FLASH, OFF2
   call   FLASHOFF2

   btfsc   FLASH, ON3
   call   FLASHON3

   btfsc   FLASH, OFF3
   call   FLASHOFF3

   btfsc   FLASH, ON4
   call   FLASHON4

   btfsc   FLASH, OFF4
   call   FLASHOFF4

   btfsc   FLASH, ON5
   call   FLASHON5

   btfsc   FLASH, OFF5
   call   FLASHOFF5

   btfss   GPIO,BUTTON      ;Button read
   bsf      FLAGS,DBN

   btfsc   FLAGS,DBN
   call   Waitup   

   bsf      GPIO,RCOM      ;Relatch RCOM high

   movlw   0x04
   movwf   CMCON0            ;comparator on

   goto   Start
   

   



; initialize eeprom locations

   ORG   0x2100
   DE   0x00, 0x01, 0x02, 0x03


   END                       ; directive 'end of program'

thax for the help dear!!!!

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.5 © 2008-2012, SimplePortal