Menu

banking in subroutines

Santiago
2009-08-09
2013-05-30
  • Santiago

    Santiago - 2009-08-09

    Compiling this code with last update (0.9 9/8/2009):

    #chip 16F876a, 20     

    my_sub

    Sub my_sub
        ADCON1 = 128
        ADCON0 = 128
    end sub

    I have this in asm:

    ;********************************************************************************

    MY_SUB
        movlw    128
        banksel    ADCON1
        movwf    ADCON1
        movlw    128
        movwf    ADCON0
        banksel    STATUS
        return

    ;********************************************************************************
    ADCON1 is in bank1 and ADCON0 is in Bank0, a banksel is needed before movwf    ADCON0

    But if i compile this code:

    #chip 16F876a, 20     

        ADCON1 = 128
        ADCON0 = 128

    I have this in asm:

    ;Start of the main program
        movlw    128
        banksel    ADCON1
        movwf    ADCON1
        movlw    128
        banksel    ADCON0
        movwf    ADCON0
    BASPROGRAMEND

    Now The banking is ok.

    I have the same results with (0.9 16/6/2009)
    but have correct banking with (0.9 24/1/2009)

     
    • Santiago

      Santiago - 2009-08-09

      Interesting...
      If i compile this code:

      #chip 16F876a, 20       'modelo de pic y velocidad de reloj

      my_sub

      Sub my_sub
          ADCON1 = 128
          ADCON0 = 128
          nop
      end sub

      I have the correct banking:

      ;********************************************************************************

      MY_SUB
          movlw    128
          banksel    ADCON1
          movwf    ADCON1
          movlw    128
          banksel    ADCON0
          movwf    ADCON0
          nop
          return

      ;********************************************************************************

       
    • Hugh Considine

      Hugh Considine - 2009-08-12

      Not sure what was causing that, but I've rewritten the bank selection code (it had other problems), so that bug is now fixed in the latest update.

       
    • Santiago

      Santiago - 2009-08-13

      Right... bug fixed. thanks 1+

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.