Ken Parkyn wrote: > > Hello all; > > I have programmed a PIC16C64 to act as a binary to one of 24 > decoder. > The unit worked OK for a while, then started to output > erratically. > I programmed a new PIC, but it does the same. > It worked once upon a time...anyone see what I've done wrong? > > code: > > title "chair" > p=16c64 > > PCL equ 02 > STATUS equ 03 > FSR equ 04 > PORTA equ 05 > PORTB equ 06 > PORTC equ 07 > PORTD equ 08 > PCL equ 02 > PCLATH equ 0A > INTCON equ 0B > OPTIONREG equ 81 > TRISA equ 05 > TRISB equ 06 > TRISC equ 07 > TRISD equ 08 > ;************************************** > w equ 00 > f equ 01 > ADRESS equ 20 > > ;************************************** > > bsf STATUS,5 ;go to bank 1 > movlw 0xFF > movwf TRISA ;set port a as inputs > clrf TRISB ;set ports,b,c & d as outputs > clrf TRISC > clrf TRISD > bcf STATUS,5 ;back to bank 0 > > main movf PORTA,W ;read select address into w > movwf ADRESS ;store this in ADRESS > call tableb ;call lookup table for port B > movwf PORTB ;put result out to port B > movwf ADRESS ;restore data from ADRESS > call tablec ;call lookup table for port C > movwf PORTC ;put result out to port C > movwf ADRESS ;restore data from ADRESS > call tabled ;call lookup table for port D > movwf PORTD ;put result out to port D > goto main ;repeat > > tableb addwf PCL,f > retlw 01 > retlw 02 > retlw 04 > retlw 08 > retlw 10 > retlw 20 > retlw 40 > retlw 80 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > tablec addwf PCL,f > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 01 > retlw 02 > retlw 04 > retlw 08 > retlw 10 > retlw 20 > retlw 40 > retlw 80 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > tabled addwf PCL,f > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 00 > retlw 01 > retlw 02 > retlw 04 > retlw 08 > retlw 10 > retlw 20 > retlw 40 > retlw 80 > end > > TIA. > > ________________________________________ > Ken Parkyn email: K.Parkyn@sct.gu.edu.au > Office of Technical Services, Electronics Workshop > GRIFFITH UNIVERSITY Nathan Qld.4111 Australia > P.O.Box 185 Ph:(07)3875 7289 Fax:(07)38757151 > ________________________________________ The value stored in ADRESS at the beginning of the programm must be restored in W with the mnemonic 'movf ADRESS,W' and you wrote 'movwf adresse' wich make an overmemory branch when the result of the table is 80 for example . Nice work JEAN-PIERRE