Haven't followed this thread BUT your calls from within a subroutine to the same subroutine are re-entrant and will rapidly run off the end of the subroutine return stack. Perhaps this is scrambling MPLABS brain. eg Loop ... ... CALL Loop will add a return address every time the "call loop" is executed. A goto would be in order. Russell McMahon _____________________________ >From another world - www.easttimor.com What can one man* do? Help the hungry at no cost to yourself! at http://www.thehungersite.com/ (* - or woman, child or internet enabled intelligent entity :-)) -----Original Message----- From: Ben Stragnell To: PICLIST@MITVMA.MIT.EDU Date: Saturday, 16 October 1999 17:20 Subject: Re: Still no solution to the problem in the following script? >Mathew, > >Is this error actually an error, or just a warning? > >It's been a while since I used MPLAB, but I seem to recall it throwing >up a warning whenever you access a register in bank 1. The only reason >you're not getting a warning on the InitPortX functions is that you're >referring to TRISA and TRISB as PORTA and PORTB. > >Also, as someone else pointed out, you're using call and goto in a >slightly unusual manner. > >Cheers, >Ben > > > >> Mathew Cohen wrote: >> >> Thankyou to the people who who have given suggestions and help for the >> following code, but no body has solved the problem of the " not in >> bank 0 " error that it generates. Also the code does not work when >> burn to a pic. When simulated it works fine until it hit a loop. Then >> MPLAB starts "dinging" me (making an error sound) I am not sure what >> thats for I think it is to do with the loop being endless.??/ >> >> So can someone stop the error and give a definite answer as to why the >> code is counted as an error. Also why the code does not work on the >> pic. >> >> The error is in the "Inttmr" routine. >> >> Thanks (the code is below) >> >> Mathew Cohen >> >> mmjcohen@nsw.bigpond.net.au >> >> ;************************************************************************** >> ; INOUT.ASM >> ; >> ;This is a simple programs that pass the value entered into portb to >> porta. >> ;If portb bit 7 is high it does a little led chase. >> ; >> ; >> ; >> ;************************************************************************** >> >> LIST P=16F84, R=DEC >> >> include "p16f84.inc" >> __FUSES _CP_OFF & _WDT_OFF & _HS_OSC ;Set default config >> >> ;-------------------------------------------------------------------------- >> >> ScratchPadRam EQU 0x20 >> >> ;-------------------------------------------------------------------------- >> ; Variables >> ;-------------------------------------------------------------------------- >> >> dipvals EQU ScratchPadRam+0 >> step1 EQU ScratchPadRam+1 >> step2 EQU ScratchPadRam+2 >> step3 EQU ScratchPadRam+3 >> step4 EQU ScratchPadRam+4 >> Steppos EQU ScratchPadRam+5 >> Temp EQU ScratchPadRam+6 >> >> ;-------------------------------------------------------------------------- >> ; Program Code >> ;-------------------------------------------------------------------------- >> ;-------------------------------------------------------------------------- >> ; Set the reset vector here. If you are using a PIC16C5X device, >> use: >> ; ORG >> ; Otherwise, use: >> ; ORG 0 >> ;-------------------------------------------------------------------------- >> >> ORG 0 >> GOTO Start >> >> ;-------------------------------------------------------------------------- >> ; Main Program >> ;-------------------------------------------------------------------------- >> >> ORG H'50' >> >> Start >> MOVLW B'00000001' >> MOVWF step1 >> MOVLW B'00000010' >> MOVWF step2 >> MOVLW B'00000100' >> MOVWF step3 >> MOVLW B'00001000' >> MOVWF step4 >> CALL InitPortA ; Sets up porta to be outputs >> CALL InitPortB ; Sets up portb to be inputs >> CALL Chase >> CALL Loop ; Pass value on portb to porta >> >> ;-------------------------------------------------------------------------- >> >> Loop >> MOVF PORTB,w ; Read Portb into w register >> MOVWF PORTA ; Move W into Porta >> BTFSC W,7 ; If bit 7 is set goto Chase >> CALL Chase >> CALL Loop >> >> ;-------------------------------------------------------------------------- >> InitPortA >> BSF STATUS,RP0 ; Select bank 1 >> MOVLW 0 ; Clears w register >> MOVWF PORTA ; Set port a as outputs >> BCF STATUS,RP0 ; Select page 0 >> MOVWF PORTA >> RETURN >> >> ;-------------------------------------------------------------------------- >> InitPortB >> BSF STATUS,RP0 ; Select bank 1 >> MOVLW 255 ; >> movwf PORTB ; Set port a as outputs >> bcf STATUS,RP0 ; Select page 0 >> RETURN >> >> ;-------------------------------------------------------------------------- >> >> Chase >> Goto Inttmr ; Initialise timer >> BTFSS PORTB,7 >> CALL Loop >> BTFSS INTCON,2 ; If timer has overflowed than skip next >> CALL Chase >> GOTO Step >> >> ;-------------------------------------------------------------------------- >> >> Inttmr >> BCF STATUS,RP0 >> CLRF TMR0 ; Clear timer >> BCF INTCON,INTF ; Clears the interupt if set >> BSF STATUS,RP0 >> movlw B'00000111' ; Set prescaler to 255 >> movwf OPTION_REG ; Option reg >> BCF STATUS,RP0 >> RETURN >> >> ;-------------------------------------------------------------------------- >> >> Step >> BCF INTCON,2 ; Clear the interupt >> BCF STATUS,RP0 ; Select page 0 >> INCF Steppos,1 >> MOVF Steppos,w >> MOVWF Temp >> MOVLW 1 >> SUBLW Temp >> BTFSC STATUS,2 >> MOVLW step1 >> MOVWF PORTA ; Output Step 1 >> MOVF Steppos,w >> MOVWF Temp >> MOVLW 2 >> SUBLW Temp >> BTFSC STATUS,2 >> MOVLW step2 >> MOVWF PORTA ; Output Step 2 >> MOVF Steppos,w >> MOVWF Temp >> MOVLW 3 >> SUBLW Temp >> BTFSC STATUS,2 >> MOVLW step3 >> MOVWF PORTA ; Output Step 3 >> MOVF Steppos,w >> MOVWF Temp >> MOVLW 4 >> SUBLW Temp >> BTFSC STATUS,2 >> MOVLW step4 >> MOVWF PORTA ; Output Step 4 >> MOVLW 0 >> MOVWF Steppos >> RETURN >> >> >> >> END >