READAD

Anobium
2012-03-26
2013-05-30
  • Anobium
    Anobium
    2012-03-26

    What I am doing wrong? (I am still learing this language).

    I get the following message when I build using MPLAB IDE - ' 46 : Register in operand not in bank 0.  Ensure that bank bits are correct.'.  I comile, then i transfer the ASM code to MPLAB then build and program.  The I get the error message when I have READAD active.

    Thank you.

    :-)

    #chip 16F1937, 32

    #define LED0Port RE0
    #define LED1Port RE1
    #define LED2Port RE2
    #define LED3Port RD1

    #define Volt RB0
    #define Pot RB2

    #config Osc = int, MCLRE=ON, WDT=OFF
    'Set the pin directions

    DIR PORTE OUT
    DIR PORTD OUT

    DIR B0 OUT
    DIR B2 IN

    dim PotVal as BYTE

    for nloop = 1 to 2
    WAIT 1000 ms
    Set Volt on
    WAIT 500 ms
    Set Volt off
    next

    main:

    PotVal = ReadAD(AN0)

    Select Case PotVal

    Case PotVal > 190
    Set LED0Port on
    Set LED1Port on
    Set LED2Port on
    Set LED3Port on

    Case PotVal > 127
    Set LED0Port on
    Set LED1Port on
    Set LED2Port on
    Set LED3Port off

    Case PotVal > 63
    Set LED0Port on
    Set LED1Port off
    Set LED2Port off
    Set LED3Port off

    Case PotVal < 10
    Set LED0Port off
    Set LED1Port off
    Set LED2Port off
    Set LED3Port off

    End Select

    goto main

     
  • Its just a warning that MPLAB/MPASM issues by default . It doesn't necessarily indicate a problem with the program its just a reminder that some of the registers being used are not in bank 0 so you need to make sure that the bank bits are set correctly. If you're writing in assembly that can be useful to know but GCBasic usually does the bank select stuff pretty well so you can probably ignore those warnings.