PDA

View Full Version : Declaring word-variables in bank15 on a pic18f2431 ?



BigWumpus
- 25th October 2006, 09:10
Hello,
I want to use the 16-bit-values inside CAP1BUFL & CAP1BUFH in PBP.

I wrote:

CAP1BUF Var word $F68

the resulting error says, the declaration is "out of bounds".
So I changed the file 18f2431.bas and inserted:

bank15 $0F60, $0FFF

and I know, it's dangerous !

How can it be made the right way ???

sayzer
- 25th October 2006, 09:43
Hi BigWumpus,

Did you try it without declaring a specific bank location?

As much as I can remember, a word variable can not fit into BANK15 .

Just a small glint I had in my mind


-----------------------------

Edit: Also,

<img src="http://img4.picsplace.to/img4/26/err_001.JPG" alt="Image Hosting by PicsPlace.to" >


----------------------------

Bruce
- 25th October 2006, 17:11
You don't need to do anything special with PBP to access special function
registers. Just use the register name like you would with any other part.

You have several options;


CAPBUF VAR WORD
CAPBUF = 0

@CAP1Buffer = CAP1BUFL
CAP1Buffer VAR WORD EXT

CAP1BUFL = 10
CAP1BUFH = 88

Main:

WithPBP:
CAPBUF.LowByte = CAP1BUFL ' low byte
CAPBUF.HighByte = CAP1BUFH ' high byte
GOTO Main

TheDarrelWay:
CAPBUF = CAP1Buffer
GOTO Main

' Or in asembler.

TheMovffWay:
@ MOVFF CAP1BUFL, _CAPBUF ; low byte
@ MOVFF CAP1BUFH, _CAPBUF+1 ; high byte
GOTO Main

TheLongWay: ' banked method
@ MOVLB 0x0F ; point to bank 15
@ MOVF CAP1BUFL,W ; low byte
@ MOVWF _CAPBUF,ACCESS
@ MOVF CAP1BUFH,W ; high byte
@ MOVWF _CAPBUF+1,ACCESS
GOTO Main

BigWumpus
- 25th October 2006, 18:19
I take Darrels way !!!! This is what I'm looking for !

Darrel Taylor
- 25th October 2006, 21:57
WooHoo! :D

Don't know if you're using more than 1 of them, but if you want to access all 3 as an array, you can also do something like this...
@CAP = CAP3BUFL
CAP VAR WORD EXT
CAPBUF VAR WORD
Index VAR BYTE

FOR Index = 1 to 3
CAPBUF = CAP(3-Index)
HSEROUT ["CAP",DEC1 Index,"= ",DEC CAPBUF,13,10]
NEXT Index
It would have been easier if they hadn't put them in reverse order in RAM.

Bruce
- 25th October 2006, 22:32
I take Darrels way !!!! This is what I'm looking for !
I hear ya..! Mr. Wizard, err, Darrel, comes up with some pretty handy
stuff..:o