# Problems with Trisb, Trisa. !!HELP PLEASE!!

Status
Not open for further replies.

#### firesky1982

##### Newbie level 3
how to set trisa and trisb

I can not get the code to build corectly. Here is the code:
Code:
	ORG	0
PowerOn		BSF	STATUS,RP0		;Select file bank 1
MOVLW	H'00'
MOVWF	TRISB			;Set all PORTB bits as outputs (display driver)
MOVWF	TRISA			;Set all PORTA bits as outputs (will be inputs in future version)
MOVLW	B'11010111'		;Turn off PORTB pullups, prescaler to TMR0, 1:256 scaling
MOVWF	OPTION_REG
this is the error message I get: Register in operand not in bank 0. Ensure that bank bits are correct.
If anyone can help me I have the same problem with all of my code with trisb,a.
MCU:16F84A
Thanks,
Garett

#### VVV

What you are getting is a just warning. TRIS registers and OPTION are in bank one, therefore, you need to set the RP0 in the STATUS register before writing to the TRIS OPTION registers. You are doing that, but the assembler is not smart enough and it still generates the warning.
However, the code will work, since these are warnings only. There must be another error message that actually prevents the build. Please check for it.

Make sure you clear the RP0 bit once you are done writing to the TRIS and OPTION registers.

#### unmonje

##### Junior Member level 1
try this:
----------------------------------------------------------------------
ORG 0x0
goto Power on
ORG 0x4
(espacio para interrupciones)
...............

org 0x30 ... o 0x40 ...o 0x50 (deja espacio para interrupciones)
PowerOn
BSF STATUS,RP0 ;Select file bank 1
MOVLW 0
MOVWF TRISB
MOVWF TRISA
MOVLW 0xD7
MOVWF OPTION_REG
... sigue el codigo ...
-------------------------------------------------------------------------
SUERTE! Good luck!!

#### firesky1982

##### Newbie level 3
ok, it builds fine but still will not program for some reason. I cant read hex code but the error is in the begining.

#### VVV

The fact that you cannot program the PIC may be an entirely different matter, related to the programmer for example.

I am sorry, I do not understand what you mean by not being able to read hex and the error being in the beginning. If there is an error, you will not get a hex file.

#### pcesarzabala

##### Newbie level 1
I THINK THAT IS EASY TO KNOW THE PROBLEM, AND THE PROBLEM IS A GAME OF BANKS TRY INCHANGE OF TRISA OR TRISB TO WRITE PORTA AND PORTB RESPEC.
AND BE SURE THAT THE BANK BIT IS IN THE WANTED, I MEAN IN BANK 1 FOR TRIS FUNCTIONS THATS ALL I CALL THIS A MAPPING TROUBLE.

#### Ghassan Al-Mutawa

##### Junior Member level 3
i dont think you have a problem

you have to move your code below

org 0x08, and every thing will work all right

example

org 0x01

goto START

org 0x04

; intrups

org 0x08 ; HERE IS YOUR CODE

START

banksel TRISB ; SELECTS THE BANK IN WHICH TRISB EXISTS
CLRF TRISB ; SET ALL PORT B TO OUTPUT
MOVLW 0XFF
MOVWF TRISA ; TO SET ALL PORTA TO INPUT

END

Status
Not open for further replies.