Hey
I am getting an error with the following asm file. The error
says that the register that I am trying to access is in a different bank can
someone help.
;**************************************************************************
;
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 <last program memory
location>
; 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,2 ; Clears the interupt if
set
BSF STATUS,RP0
movlw
B'00000111' ; Set prescaler to
255
movwf OPTION_REG ; Option
reg
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
Thanks