Error 302: "Register in operand not in bank 0" ?

Author
ipscone
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2006/08/02 10:43:34
  • Location: 0
  • Status: offline
2006/09/19 06:54:44 (permalink)
0

Error 302: "Register in operand not in bank 0" ?

I am using MPLAB IDE v7.40 with MPLAB ICD2 to program a 16F690 chip in a PICkit2 board.  I am getting on error, in many places, on most applications.  The error is always the same.

I am assembling the lesson programs and getting this message.  It's not an error because it does create the HEX file but the program does not run properly.

"Message[302]REVERSIBLE.ASM 52: Register in operand not in bank 0. Ensure that bank bits are correct"

This reversible.asm and other programs are not modified and are assembled just as they were on the MicroChip site.  What is the reason for this error? What is the solution?  I have put an arrow pointing to each line in the code below where this message is produced
 org 0
Start
bsf STATUS,RP0 ; select Register Page 1
movlw 0xFF
movwf TRISA  ; Make PortA all input  ; <---- MESSAGE 302
clrf TRISC  ; Make PortC all output    ; <---- MESSAGE 302
movlw 0x10  ; A2D Clock Fosc/8
movwf ADCON1                              ; <---- MESSAGE 302
; bcf STATUS,RP0 ; back to Register Page 0
bcf STATUS,RP0 ; address Register Page 2
bsf STATUS,RP1 
movlw 0xF7  ; we want all Port A pins Analog, except RA3
movwf ANSEL                                 ; <---- MESSAGE 302
bcf STATUS,RP0 ; address Register Page 0
bcf STATUS,RP1
The program simply displays a rotating blinking light.  When you press the button, the lights are supposed to reverse direction.  I can assemble this program and program the 16F690 and the lights do rotate.  However, they do not reverse.  I suspect it has something to do with this message that is the source of the problem but don't understand why this message is produced.
post edited by ipscone - 2006/09/19 06:57:29
#1

7 Replies Related Threads

    ric
    Super Member
    • Total Posts : 22101
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    RE: Error 302: "Register in operand not in bank 0" ? 2006/09/19 06:56:25 (permalink)
    0
    This is not an "error". It is a "message". You file has assembled ok.
     
    It is just reminding you to check you have the correct bank selected, and is printed every time you access a register which is not in bank 0.
    It is just there for beginners, and can be disabled easily.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    ipscone
    Starting Member
    • Total Posts : 56
    • Reward points : 0
    • Joined: 2006/08/02 10:43:34
    • Location: 0
    • Status: offline
    RE: Error 302: "Register in operand not in bank 0" ? 2006/09/19 07:31:26 (permalink)
    0
    Well, I did say message in a couple of places.  I understand it's not an error.  In fact, I said it's not an error. I just incorrectly called it an error in a couple of places.    But I do wonder what you mean by "check you have the correct bank selected".    If it's "not in bank 0" doesn't that imply something wrong?

    Oh! I just realized something.  If I remove the ICSP cable, it runs fine and reverses. Not quite sure why but that is another story for later.

    I would like to go back to my the MESSAGE 302 issue. 

    I guess the thing that is puzzling to me, is that I have looked at the memory map for the 16F690 and there is no TRISA in bank 0 at all (for example).  All they show is one in Bank 1 and Bank 3.  So, if there is NEVER one in bank 0, why the need for the message?  And if bank 1 or bank 3 is correct, for setting TRISA, and if my program is correctly selecting bank 1 (register bank 1), as it should, why the need for the message, at all.  It's almost as if it's saying, "you are doing this right and I'm sending the message to let you know you didn't do it wrong".  Very wierd.
     
    I'm a bit confused on what this message is actually warning me of.  Can you give me  a brief more detailed explanation?

    Thanks,
    post edited by ipscone - 2006/09/19 07:41:07
    #3
    ric
    Super Member
    • Total Posts : 22101
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    RE: Error 302: "Register in operand not in bank 0" ? 2006/09/19 15:38:05 (permalink)
    0
    ORIGINAL: ipscone

    Well, I did say message in a couple of places.  I understand it's not an error.  In fact, I said it's not an error. I just incorrectly called it an error in a couple of places.

    In particular, the subject of your message was "Error 302: "Register in operand not in bank 0" ?", so you changed message -> error.
     
        But I do wonder what you mean by "check you have the correct bank selected".    If it's "not in bank 0" doesn't that imply something wrong?

    No. Some registers are in bank 0, some are not. Te assembler is dumb, it makes this comment for every access to a register in a bank other than 0, because it does not track your code to see which bank is selected.


    That is puzzling to me, is that I have looked at the memory map for the 16F690 and there is no TRISA in bank 0 at all (for example).  All they show is one in Bank 1 and Bank 3.  So, if there is NEVER one in bank 0, why the need for the message?  And if bank 1 or bank 3 is correct, for setting TRISA, and if my program is correctly selecting bank 1 (register bank 1), as it should, why the need for the message, at all.

    See above. Yes, the message can be confusing. It is asking you to make sure you have the correct bank selected. It does not know that you have.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    ipscone
    Starting Member
    • Total Posts : 56
    • Reward points : 0
    • Joined: 2006/08/02 10:43:34
    • Location: 0
    • Status: offline
    RE: Error 302: "Register in operand not in bank 0" ? 2006/09/21 10:00:58 (permalink)
    0
    So, is there a way to turn off this error, without turning off something else that one might want to know about?
    #5
    violin
    Super Member
    • Total Posts : 3301
    • Reward points : 0
    • Joined: 2005/05/09 04:59:48
    • Status: offline
    RE: Error 302: "Register in operand not in bank 0" ? 2006/09/21 10:11:40 (permalink)
    0
            errorlevel    -302
    #6
    Ron Hayes
    Super Member
    • Total Posts : 1316
    • Reward points : 0
    • Joined: 2003/11/07 12:38:10
    • Location: Ontario, Canada
    • Status: offline
    RE: Error 302: "Register in operand not in bank 0" ? 2006/09/21 11:33:25 (permalink)
    0
    You can make yourself a maco that turns off the errorlevel 302 and sets the bank then another macro that turns the errorlevel back on and clears the bank. In this way if you ever do use a register that has not been banked properly you'll know it.

    Ron
    #7
    khaynes
    Starting Member
    • Total Posts : 40
    • Reward points : 0
    • Joined: 2005/07/03 16:27:08
    • Status: offline
    RE: Error 302: "Register in operand not in bank 0" ? 2006/09/21 11:36:01 (permalink)
    0
    Hi,
     
    I manage my bank selection manually using the following macros.
     
    ; Memory Bank select macros
    BANKSEL_0 MACRO
        errorlevel +302 ; Enable bank switch warning
        bcf STATUS, RP0
        bcf STATUS, RP1
        ENDM
    BANKSEL_1 MACRO
        bsf STATUS, RP0
        bcf STATUS, RP1
        errorlevel -302 ; Disable bank switch warning
        ENDM
     
    ; Used like this:
       movlw SCR_PR2_INIT ; set Period = 20uS
       BANKSEL_1
       movwf PR2
       BANKSEL_0
     
    This works since my program is small and I only go to bank 1 for reaching SFR's.  It also only works for one type of PIC, because SFR's are sometimes in different banks in different PICs.  I use the policy of switching to bank 1 for as short a time as possible.  This way, the bank warnings are disabled for as short a time as possible.
     
    Keith


    #8
    Jump to:
    © 2018 APG vNext Commercial Version 4.5