Declaring word-variables in bank15 on a pic18f2431 ?


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289

    Question Declaring word-variables in bank15 on a pic18f2431 ?

    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 ???
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    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" >


    ----------------------------
    Last edited by sayzer; - 25th October 2006 at 12:32.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    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;
    Code:
        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
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Thumbs up

    I take Darrels way !!!! This is what I'm looking for !
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Post

    WooHoo!

    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...
    Code:
    @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.
    DT

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BigWumpus
    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..
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  2. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 07:25
  3. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  4. DS2760 Thermocouple Kit from Parallax in PicBasicPro
    By seanharmon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th July 2008, 23:19
  5. calculation problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2006, 15:23

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts