;=============Pedalboard PIC code JFETs 10ms mute===============2009 10 21===
list p=pic16f737
#include <P16F737.inc> ; processor specific variable definitions
radix hex
;
__CONFIG _CONFIG1, _CP_OFF & _CCP2_RB3 & _DEBUG_OFF & _VBOR_2_0 & _BOREN_0 & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO
__CONFIG _CONFIG2, _BORSEN_0 & _IESO_OFF & _FCMEN_OFF
;------------------------------------------------------------
; Counter locations
dbcount equ 0x21
dc1 equ 0x22
dbcount_2 equ 0x23
;------------------------------------------------------------
org 0x000
;
;Initialization
start bsf STATUS,RP0
bcf STATUS,RP1 ;bank 1
bsf OSCCON,IRCF2 ;set int osc 110=4Mhz
bsf OSCCON,IRCF1
bcf OSCCON,IRCF0
movlw 0x0F ;conifgure all pins as
movwf ADCON1 ; digital inputs
bcf OPTION_REG,7 ;enable PORTB pullups
movlw 0x1F ;load w with 00011111
movwf TRISA ;make RA0-RA4 inputs,RA5-RA7 outputs
movlw 0xFF ;load w with 1's
movwf TRISB ;make PORTB inputs
movlw 0x00 ;load w with 0's
movwf TRISC ;make PORTC outputs
bcf STATUS, RP0 ;bank 0
bsf PORTA,6 ;output hi RA6 - mute on
nop
bsf PORTA,5 ;output hi RA5 - vb off
nop
bsf PORTA,7 ;output hi RA7 - lead channel on
movlw 0x55 ;load w with 01010101
movwf PORTC ;all effects bypassed
bcf PORTA,6 ;output lo RA6 - mute off
;Main Program
switch btfss PORTE,3 ;bypass switch hi?
goto bypass ;no - swtich pressed
btfss PORTA,0 ;comp vb switch hi?
goto compvb ;no - switch pressed
btfss PORTA,1 ;comp switch hi?
goto comp ;no - switch pressed
btfss PORTA,2 ;flanger switch hi?
goto flanger ;no - switch pressed
btfss PORTA,3 ;chorus switch hi?
goto chorus ;no - switch pressed
btfss PORTA,4 ;delay switch hi?
goto delay ;no - switch pressed
btfss PORTB,0 ;comp delay switch hi?
goto compdelay ;no - switch pressed
btfss PORTB,1 ;comp flanger switch hi?
goto compflanger ;no - switch pressed
btfss PORTB,2 ;ch delay switch hi?
goto chdelay ;no - switch pressed
btfss PORTB,3 ;clch delay switch hi?
goto clchdelay ;no - switch pressed
btfss PORTB,4 ;cl flanger switch hi?
goto clflanger ;no - switch pressed
btfss PORTB,5 ;cl chorus switch hi?
goto clchorus ;no - switch pressed
btfss PORTB,6 ;clean switch hi?
goto clean ;no - switch pressed
btfss PORTB,7 ;comp delay vb switch hi?
goto compdlyvb ;no - switch pressed
goto switch ;check all switches again
; Switch Actions
;
bypass bsf PORTA,6 ;turn mute on
; debounce switch down
db_down movlw 0x1A ;max count = 20ms/768us = 26 = 0x1A
movwf dbcount
clrf dc1 ;reset dc1
dn_dly incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly
btfsc PORTE,3 ;if button up (RE3 hi),
goto db_down ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly
; actual switching
call mutedelay ;mute for 1s
bsf PORTA,5 ;output hi RA5 - vb off
nop
bsf PORTA,7 ;output hi RA7 - lead channel on
movlw 0x55 ;load w with 01010101
movwf PORTC ;all effects bypassed
bcf PORTA,6 ;turn mute off
; debounce switch up
db_up movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly incfsz dc1,f ;delay 256x3 = 768us
goto up_dly
btfss PORTE,3 ;if button down (RE3 lo),
goto db_up ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly
goto switch
compvb bsf PORTA,6 ;turn mute on
; debounce switch down
db_down1 movlw 0x1A ;max count = 20ms/768us = 26 = 0x1A
movwf dbcount
clrf dc1 ;reset dc1
dn_dly1 incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly1
btfsc PORTA,0 ;if button up (RA0 hi),
goto db_down1 ;restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly1
; actual switching
call mutedelay ;mute for 1s
movlw b'01010110'
movwf PORTC ;turn comp on
bcf PORTA,5 ;output lo RA5 - vb on
nop
bsf PORTA,7 ;output hi RA7 - lead channel on
bcf PORTA,6 ;turn mute off
; debounce switch up
db_up1 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly1 incfsz dc1,f ;delay 256x3 = 768us
goto up_dly1
btfss PORTA,0 ;if button down (RA0 = lo),
goto db_up1 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly1
goto switch ;check switches again
comp bsf PORTA,6 ;turn mute on
; debounce switch down
db_down2 movlw 0x1A ;max count = 20ms/768us = 26 = 0x1A
movwf dbcount
clrf dc1 ;reset dc1
dn_dly2 incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly2
btfsc PORTA,1 ;if button up (RA1 hi),
goto db_down2 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly2
; actual switching
movlw b'01010110'
movwf PORTC ;turn comp on
bsf PORTA,5 ;output hi RA5 - vb off
nop
bsf PORTA,7 ;output hi RA7 - lead channel on
call mutedelay ;mute for 1s
; debounce switch up
db_up2 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly2 incfsz dc1,f ;delay 256x3 = 768us
goto up_dly2
btfss PORTA,1 ;if button down (RA1 lo),
goto db_up2 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly2
bcf PORTA,6 ;turn mute off
goto switch ;check switches again
flanger bsf PORTA,6 ;turn mute on
; debounce switch down
db_down3 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
dn_dly3 incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly3
btfsc PORTA,2 ;if button up (RA2 hi),
goto db_down3 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly3
; actual switching
call mutedelay ;mute for 1s
movlw b'01011001'
movwf PORTC ;turn flanger on
bsf PORTA,5 ;output hi RA5 - vb off
nop
bsf PORTA,7 ;output hi RA7 - lead channel on
; debounce switch up
db_up3 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly3 incfsz dc1,f ;delay 256x3 = 768us
goto up_dly3
btfss PORTA,2 ;if button down (RA2 = lo),
goto db_up3 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly3
bcf PORTA,6 ;turn mute off
goto switch ;check switches again
chorus bsf PORTA,6 ;turn mute on
; debounce switch down
db_down4 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
dn_dly4 incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly4
btfsc PORTA,3 ;if button up (RA3 hi),
goto db_down4 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly4
; actual switching
call mutedelay ;mute for 1s
movlw b'01100101'
movwf PORTC ;turn chorus on
bsf PORTA,5 ;output hi RA5 - vb off
nop
bsf PORTA,7 ;output hi RA7 - lead channel on
; debounce switch up
db_up4 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly4 incfsz dc1,f ;delay 256x3 = 768us
goto up_dly4
btfss PORTA,3 ;if button down (RA3 lo),
goto db_up4 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly4
bcf PORTA,6 ;turn mute off
goto switch ;check switches again
delay bsf PORTA,6 ;turn mute on
; debounce switch down
db_down5 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
dn_dly5 incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly5
btfsc PORTA,4 ;if button up (RA4 hi),
goto db_down5 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly5
; actual switching
call mutedelay ;mute for 1s
movlw b'10010101'
movwf PORTC ;turn delay on
bsf PORTA,5 ;output hi RA5 - vb off
nop
bsf PORTA,7 ;output hi RA7 - lead channel on
; debounce switch up
db_up5 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly5 incfsz dc1,f ;delay 256x3 = 768us
goto up_dly5
btfss PORTA,4 ;if button down (RA4 lo),
goto db_up5 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly5
bcf PORTA,6 ;turn mute off
goto switch ;check switches again
compdelay bsf PORTA,6 ;turn mute on
; debounce switch down
db_down6 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
dn_dly6 incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly6
btfsc PORTB,0 ;if button up (RB0 hi),
goto db_down6 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly6
; actual switching
call mutedelay ;mute for 1s
movlw b'10010110'
movwf PORTC ;turn comp and delay on
bsf PORTA,5 ;output hi RA5 - vb off
nop
bsf PORTA,7 ;output hi RA7 - lead channel on
; debounce switch up
db_up6 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly6 incfsz dc1,f ;delay 256x3 = 768us
goto up_dly6
btfss PORTB,0 ;if button down (RB0 lo),
goto db_up6 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly6
bcf PORTA,6 ;turn mute off
goto switch ;check switches again
compflanger bsf PORTA,6 ;turn mute on
; debounce switch down
db_down7 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
dn_dly7 incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly7
btfsc PORTB,1 ;if button up (RB1 hi),
goto db_down7 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly7
; actual switching
call mutedelay ;mute for 1s
movlw b'01011010'
movwf PORTC ;turn comp and flanger on
bsf PORTA,5 ;output hi RA5 - vb off
nop
bsf PORTA,7 ;output hi RA7 - lead channel on
; debounce switch up
db_up7 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly7 incfsz dc1,f ;delay 256x3 = 768us
goto up_dly7
btfss PORTB,1 ;if button down (RB1 lo),
goto db_up7 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly7
bcf PORTA,6 ;turn mute off
goto switch ;check switches again
chdelay bsf PORTA,6 ;turn mute on
; debounce switch down
db_down8 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
dn_dly8 incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly8
btfsc PORTB,2 ;if button up (RB2 hi),
goto db_down8 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly8
; actual switching
call mutedelay ;mute for 1s
movlw b'10100101'
movwf PORTC ;turn chorus and delay on
bsf PORTA,5 ;output hi RA5 - vb off
nop
bsf PORTA,7 ;output hi RA7 - lead channel on
; debounce switch up
db_up8 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly8 incfsz dc1,f ;delay 256x3 = 768us
goto up_dly8
btfss PORTB,2 ;if button down (RB2 lo),
goto db_up8 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly8
bcf PORTA,6 ;turn mute off
goto switch ;check switches again
clchdelay bsf PORTA,6 ;turn mute on
; debounce switch down
db_down9 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
dn_dly9 incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly9
btfsc PORTB,3 ;if button up (RB3 hi),
goto db_down9 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly9
; actual switching
call mutedelay ;mute for 1s
movlw b'10100101'
movwf PORTC ;turn chorus and delay on
bsf PORTA,5 ;output hi RA5 - vb off
nop
bcf PORTA,7 ;output lo RA7 - clean channel on
; debounce switch up
db_up9 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly9 incfsz dc1,f ;delay 256x3 = 768us
goto up_dly9
btfss PORTB,3 ;if button down (RB3 lo),
goto db_up9 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly9
bcf PORTA,6 ;turn mute off
goto switch ;check switches again
clflanger bsf PORTA,6 ;turn mute on
; debounce switch down
db_down10 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
dn_dly10 incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly10
btfsc PORTB,4 ;if button up (RB4 hi),
goto db_down10 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly10
; actual switching
call mutedelay ;mute for 1s
movlw b'01011001'
movwf PORTC ;turn flanger on
bsf PORTA,5 ;output hi RA5 - vb off
nop
bcf PORTA,7 ;output lo RA7 - clean channel on
; debounce switch up
db_up10 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly10 incfsz dc1,f ;delay 256x3 = 768us
goto up_dly10
btfss PORTB,4 ;if button down (RB4 lo),
goto db_up10 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly10
bcf PORTA,6 ;turn mute off
goto switch ;check switches again
clchorus bsf PORTA,6 ;turn mute on
; debounce switch down
db_down11 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
dn_dly11 incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly11
btfsc PORTB,5 ;if button up (RB5 hi),
goto db_down11 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly11
; actual switching
call mutedelay ;mute for 1s
movlw b'01100101'
movwf PORTC ;turn chorus on
bsf PORTA,5 ;output hi RA5 - vb off
nop
bcf PORTA,7 ;output lo RA7 - clean channel on
; debounce switch up
db_up11 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly11 incfsz dc1,f ;delay 256x3 = 768us
goto up_dly11
btfss PORTB,5 ;if button down (RB5 lo),
goto db_up11 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly11
bcf PORTA,6 ;turn mute off
goto switch ;check switches again
clean bsf PORTA,6 ;turn mute on
; debounce switch down
db_down12 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
dn_dly12 incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly12
btfsc PORTB,6 ;if button up (RB6 hi),
goto db_down12 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly12
; actual switching
call mutedelay ;mute for 1s
movlw b'01010101'
movwf PORTC ;turn chorus and delay on
bsf PORTA,5 ;output hi RA5 - vb off
nop
bcf PORTA,7 ;output lo RA7 - clean channel on
; debounce switch up
db_up12 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly12 incfsz dc1,f ;delay 256x3 = 768us
goto up_dly12
btfss PORTB,6 ;if button down (RB6 lo),
goto db_up12 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly12
bcf PORTA,6 ;turn mute off
goto switch ;check switches again
compdlyvb bsf PORTA,6 ;turn mute on
; debounce switch down
db_down13 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
dn_dly13 incfsz dc1,f ;delay 256x3 = 768us
goto dn_dly13
btfsc PORTB,7 ;if button up (RB7 hi),
goto db_down13 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto dn_dly13
; actual switching
call mutedelay ;mute for 1s
movlw b'10010110'
movwf PORTC ;turn comp and delay on
bcf PORTA,5 ;output lo RA5 - vb on
nop
bsf PORTA,7 ;output hi RA7 - lead channel on
; debounce switch up
db_up13 movlw 0x0D ;max count = 10ms/768us = 13 = 0x0D
movwf dbcount
clrf dc1 ;reset dc1
up_dly13 incfsz dc1,f ;delay 256x3 = 768us
goto up_dly13
btfss PORTB,7 ;if button down (RB7 lo),
goto db_up13 ; restart count
decfsz dbcount,f ;else repeat until max count is reached
goto up_dly13
bcf PORTA,6 ;turn mute off
goto switch ;check switches again
;-----------------------------------------------------------------------------
; mutedelay - 10ms delay
;
mutedelay
;9998 cycles
movlw 0xCF
movwf dbcount
movlw 0x08
movwf dc1
Delay_0
decfsz dbcount, f
goto $+2
decfsz dc1, f
goto Delay_0
;2 cycles
goto $+1
return
end