Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cblock 0x6B
- COUNT1 ;0x6B
- COUNT2 ;0x6C
- COUNT3 ;0x6D
- endc
- LINECOUNT EQU 0xEF ;lookup table line counter register
- ;****************************************************************************************
- ;* *
- ;* Restore Factory Defaults *
- ;* *
- ;****************************************************************************************
- ;defaults table is located in the top section of this code
- Restore movlw 0x00 ;EEPROM start address
- banksel EEADR ;bank 1
- movwf EEADR
- movlw 0x05 ;table start line
- movwf LINECOUNT
- movfw LINECOUNT ;move table line into W
- call Defaults ;call defaults table
- movwf EEDATA ;move table data into EEPROM Data Register
- call EEWrite ;write data to EEPROM
- call EEVerify ;verify write
- movlw 0x04 ;was line 4 the last line fetched from table?
- xorwf LINECOUNT,W
- btfsc STATUS,Z
- goto $+19 ;yes, jump line counter to line 9
- movlw 0x0A ;no, was line 10 the last line fetched from table?
- xorwf LINECOUNT,W
- btfsc STATUS,Z
- goto $+12 ;yes, reset line counter to line 5
- incf LINECOUNT,F ;no, increment table line counter
- incf EEADR,F ;increment EEPROM read address
- movlw 0x40 ;is address 0x40 next EEPROM write address?
- xorwf EEADR,W
- btfsc STATUS,Z
- clrf LINECOUNT ;yes, reset table counter to 0
- movlw 0x69 ;no, was address 0x68 last written EEPROM address?
- xorwf EEADR,W
- btfss STATUS,Z
- goto $-22 ;no, continue restoring defaults
- goto $+7 ;yes, proceed to exit
- ;-----------------------------------------------------------------------------------------------------------
- ;line counter reset routines
- movlw 0x05 ;reset line counter to line 5
- movwf LINECOUNT
- goto $-12 ;continue restoring defaults
- movlw 0x09 ;set table counter to line 9
- movwf LINECOUNT
- goto $-15
- ;-----------------------------------------------------------------------------------------------------------
- ;exit sequence
- banksel 0x00 ;bank 0
- return ;defaults restored, exit
- ;-----------------------------------------------------------------------------------------------------------
- ;factory defaults values
- Defaults addwf PCL,F
- retlw 0x00 ;Channel Select Controller Number
- retlw 0x01 ;Lead Boost Select Controller Number
- retlw 0x02 ;Effects Loop Select Controller Number
- retlw 0xB0 ;Control Change MIDI Channel 1
- retlw 0xC0 ;Program Change MIDI Channel 1
- retlw b'00010001' ;Dry Clean (0x11)
- retlw b'00010101' ;Wet Clean (0x15)
- retlw b'00010000' ;Dry Rhythm (0x10)
- retlw b'00010100' ;Wet Rhythm (0x14)
- retlw b'00010010' ;Dry Lead (0x12)
- retlw b'00010110' ;Wet Lead (0x16)
- ;****************************************************************************************
- ;* *
- ;* EEPROM Functions *
- ;* *
- ;****************************************************************************************
- EEWrite bcf INTCON,GIE ;disable all interrupts
- bsf EECON1,WREN ;enable EEPROM write mode
- movlw 0x55 ;write unlock codes (required sequence)
- movwf EECON2
- movlw 0xAA
- movwf EECON2
- bsf EECON1,WR ;initiate write to EEPROM
- btfsc EECON1,WR ;is write complete?
- goto $-1 ;no, check again
- bcf EECON1,WREN ;disable EEPROM write mode
- banksel PIR1 ;bank 0
- bcf PIR1,EEIF ;clear EEPROM write interrupt flag
- bsf INTCON,GIE ;enable all unmasked interrupts
- banksel 0x80 ;bank 1
- return
- ;****************************************************************************************
- EEVerify bcf INTCON,GIE ;disable all interrupts
- movfw EEDATA ;copy data to be verified into W
- bsf EECON1,RD ;initiate EEPROM read
- xorwf EEDATA,W ;compare EEPROM data to data in W
- btfss STATUS,Z ;are they the same?
- call WriteErr ;no, indicate write error
- bsf INTCON,GIE ;enable all unmasked interrupts
- return
- ;****************************************************************************************
- ;illuminate Learn LED for 1/2 second to indicate EEPROM Write Error condition
- WriteErr bcf LRN_LED
- call Delay_500mS
- bsf LRN_LED
- return
- ;****************************************************************************************
- ;* *
- ;* Delay Loops *
- ;* *
- ;****************************************************************************************
- ;50mS Delay
- Delay_50mS movlw 0xFF
- movwf COUNT1
- movwf COUNT2
- decfsz COUNT1,F
- goto $-1
- decfsz COUNT2,F
- goto $-3
- return
- ;****************************************************************************************
- ;500mS Delay...run Delay_50mS 10 times
- Delay_500mS movlw 0x0A
- movwf COUNT3
- call Delay_50mS
- decfsz COUNT3,F
- goto $-2
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement