Menu

Is ADOff obsolete?

Help
2007-03-28
2013-05-30
  • Nobody/Anonymous

    I'm currently writing some code for the 12F675 and I want to disable the A/D converters so I used ADOff in the code which results in this:

    <-->
    ;Start of the main program
        call    ADOFF
    <-->
    ADOFF
        banksel    ADCON0
        bcf    ADCON0,ADON
        banksel    ANSEL
        clrf    ANSEL
        banksel    STATUS
        return

    But then I noticed that erlier the code calls INITSYS here:
    ;Jump to initialisation code when PIC is reset
        ORG    0
        call    INITSYS
        goto    SystemInitialise

    and INITSYS looks like this:
    INITSYS
        clrf    GPIO
        movlw    7
        movwf    CMCON
        bcf    ADCON0,ADON
        bcf    ADCON0,ADFM
        banksel    ANSEL
        clrf    ANSEL
        banksel    STATUS
        return

    I'm new to PIC coding but it looks to me like among other things INITSYS turns of the A/D converters which should make it unnecessary (and a waste of bytes) to include the ADOff command.

    Am I missing something here or could I just delete the ADOff command to save some space on the chip?

     
    • Hugh Considine

      Hugh Considine - 2007-03-30

      ADOff is now obsolete, and can be deleted. I forgot to document this, which I'll fix in the next version of GCBASIC.

      While I'm apologizing for not documenting things, I'd also like to say that GCBASIC will now set the internal oscillator speed based on the #chip line where possible. This has been the case since the 0.9.3.0 release, and any lines that set OSCCON can be deleted.

       
      • bell

        bell - 2007-03-30

        Yes, I noticed that too when I compiled my code for a 12F683.

        I also noticed another thing.

        I've setup two include files, one for 12F675 and one for 12F683.

        Since I didn't know OSCCON = <value> and ADOff was obsolete I added ADOff to the 12F675 include file and OSCCON = <value> and ADOff to the 12F683 include file.

        Well... what happens is that any code in the include file is put last in the assembler code so the chip specific changes I put in the include files are not executed until the program has done it's stuff.

        It's a big deal, now that I know how it works, and also those specific examples are obsolete but it wasn't what I expected.

        In my world any subroutine or function in the include file could go in to end of the main code but any non-subroutine/function code should be run inserted where the #include is located in the main code.

        At least that was how I thought it worked until I looked att the generated .asm file.

        BTW, thanks for excellent support. I've got a few other "misbehaves" of the compiler to report but I'll post that to the Compiler problems forum.

         

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.