So I've started a new program that does not have all the features I want. I figured it's best to start with the base and then add things once I get those working properly. The schematic is for an echo/delay sound effects unit. Right now, I'm just trying to get the on/off (bypass/trails) switch and the "DELAY TIME" potentiometer to work.

The 2 x PT2399 ICs are the delay chips. They are in series. Their delay time is controlled by the MCP4251 digital potentiometer, which is controlled by the 16F616 (note that the schematic says 16F676, but I am using the 16F616), which interfaces with the user via an analog potentiometer.

The on/off feature has two modes of operation - normal bypass and trails bypass. Normal bypass is just an on/off switch for the effect. When "ON", junction A and B are set high to allow signal to pass through the switching JFETs and junction C is low to block signal. When "OFF", junction A and B are low and junction C is high. "Trails mode" is a feature that allows the echoes to continue repeating after you turn the effect "off", but doesn't allow any new echoes to be created. So when the effect is on, it is the same as when in normal mode, but when the effect is off, junction A is low, cancelling new signal that feeds into the delay chips and the dry side of the crossfader, but junction B and C are high allowing the complete dry signal to pass and any signal that is already in the feedback loop of the delay chip.

The user can toggle between normal and trails modes by pressing and holding the bypass switch for 3 seconds. The tempo LED will blink 5 times to let the user know that the mode has changed. When the effect is on, the bypass LED is high. When it is off, the bypass LED is low.

In the code below, the bypass feature seems to work just fine. It is the delay time control that I'm having problems with. The analog potentiometer does control the delay time as it should. However, it modulates wildly, i.e., the digital potentiometer will not settle into one position once you stop turning the analog potentiometer. I have a feeling the way I've done the config or set the registers has something to do with it.

Code:
#config 
    __CONFIG _CP_OFF & _WDTE_OFF & _BOREN_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _IOSCFS_4MHZ
#endconfig

ADCON0 = %00000000
ADCON1 = %01100000
ANSEL = %00000110


CM1CON0 = %00000000
CM2CON0 = %00000000  

TRISA = %00001111
TRISC = %00000000

    
    '                      
    '    Hardware connection
    '    ===================
    CS          VAR PORTA.5
    SCK         VAR PORTC.2
    SDI          VAR PORTC.1
    tempoLED var PORTC.0
    tempobutton var PORTA.0
    bypassbutton var PORTA.3
    bypassLED var PORTC.4
    fetA var PORTC.5
    fetB var PORTA.4
    fetC var PORTC.3
    
    
    
    '   
    '    Variables definition 
    '    ===================
    w var word                          ' division toggle switch
    x var word                          ' delay time knob
    xprevious var word
    z var word
    binaryvalue var word
    
    ticks var word
    tapcount var word
    LEDcounter var word
    LEDcounterlimit var word
    LEDrate var word
    
    trailsmode var byte
    trailsmodecounter var word 
    LEDon var byte
    LEDoff var byte
    
    LEDon = 1
    LEDoff = 0
                             
    '
    '    begin in bypass
    '    ===============
    
    tempoLED = 0
    fetA = 0
    fetB = 0
    fetC = 1
    bypassLED = LEDoff
    trailsmode = 0
    
    
main:       
        gosub readpot
        if bypassBUTTON = 0 then
            gosub bypasspress
            gosub bypassbuttonrelease
        ENDif
        pause 100
        gosub movedigipot 
goto main


bypasspress:                                                  ' subroutine that occurs when bypass button is pressed
    trailsmodecounter = 0                                      ' waits to see if you want to switch between normal or trails mode
    do until trailsmodecounter = 400
        if bypassbutton = 1 then exit
        pause 10       
        trailsmodecounter = trailsmodecounter + 1
    loop
    
    if trailsmodecounter = 400 then                         ' if bypass button was held long enough then change mode
        goto trailmodechange
    endif 
    
    if trailsmode = 1 then                       ' if bypass button was not held long enough go to sub to toggle between on/off
        gosub trailsbypass
    elseif trailsmode = 0 then
        gosub normalbypass
    endif
return

trailmodechange:                ' subroutine that occurs when bypass button is held long enough to change between normal or trails mode
    if trailsmode = 1 then
        trailsmode =  0
    elseif trailsmode = 0 then
        trailsmode = 1
    endif
    
    for z = 1 to 5
    tempoLED = 1
        pause 100
    tempoLED = 0
        pause 100
    next z
    
goto main    

normalbypass:                        ' subroutine for normal bypass
    if bypassLED = 0 then
        fetA = 1
        fetB = 1
        fetC = 0
        bypassLED = LEDon
    elseif bypassLED = 1 then
        fetA = 0
        fetB = 0
        fetC = 1
        bypassLED = 0
    endif
return

trailsbypass:                       'subroutine for trails bypass
    if bypassLED = 0 then
        fetA = 1
        fetB = 1
        fetC = 0
        bypassLED = LEDon
    elseif bypassLED = 1 then
        fetA = 0
        fetB = 1
        fetC = 1
        bypassLED = LEDoff
    endif
return

bypassbuttonrelease:             ' debounce subroutine when bypass button is pressed
    do until bypassbutton = 1
        pause 10
    loop
return
       
movedigipot:

    CS=0                                        
    shiftout SDI, SCK, 1, [00000000,x]                 ' move wiper A
    shiftout SDI, SCK, 1, [00010000,x]                   'move wiper B
    CS=1   
return


readpot:    
    adcin 2,x                                       'read voltage of "delay time" pot                                                                          
return


end