Frank - 2009-08-13

I've been using an 18F26J11 chip with GCBasic. Many of the SFR's are not in the access bank but GCBasic doesn't seem to be generating Banksel's for them or addressing them as banked.

The chip also has different registers for enabling or disabling analogue pins and slightly different names for the comparator control registers so the INITSYS sub in system.h doesn't produce code to disable the analogue pins or the comparator. I've added some extra lines to initsys as follows to produce some code for these registers.

        'Clear whatever ANSEL variants the chip has
        #IFDEF Var(ANSEL)
            ANSEL = 0
        #ENDIF
        #IFDEF Var(ANSELH)
            ANSELH = 0
        #ENDIF
        #IFDEF Var(ANSEL0)
            ANSEL0 = 0
        #ENDIF
        #IFDEF Var(ANSEL1)
            ANSEL1 = 0
        #ENDIF
>        #IFDEF Var(ANCON0)
>            ANCON0 = 0xFF
>        #ENDIF
>        #IFDEF Var(ANCON1)
>            ANCON1 = 0x9F
>        #ENDIF
    #ENDIF
   
    'Turn off comparator
    #IFDEF Var(CMCON)
        CMCON = 7
    #ENDIF
    #IFDEF Var(CMCON0)
        CMCON0 = 7
    #ENDIF
    '12F510,16F506 and other devices? (Thanks to Kent for suggesting these lines!)
    #IFDEF Var(CM1CON0)
        #IFDEF Var(CM2CON0)
            C2ON = 0
        #ENDIF
        C1ON = 0
    #ENDIF
>    '18F46J11 and 46J50 families
>    #IFDEF Var(CM1CON)
>        #IFDEF Var(CM2CON)
>            CM2CON.CON = 0
>        #ENDIF
>        CM1CON.CON = 0
>    #ENDIF

The extra lines have the > at the start. They seem to generate the right code apart from the banking which is beyond me as it looks to be part of the GCBASIC.BAS code.( Microchip have changed the polarity for selecting between analogue and digital for these families so a 1 is digital)

Frank