Two PIC16 questions

  • E. van Putten
    E. van Putten

    Hi All,

    My first questions is related to the configuration space of a PIC18F device. Does anyone know how to describe the Microchip configuration bits in a .C file? I can't find anything about it in the manual.

    Secondly, there are a lot of linker errors when building a very simple project. I learned that you must first build the libraries (which aren't included in all the gzip files for some reason by the way).

    It seems that "special" symbols like PRODH, PCLATH etc are _not_ exported to object files. Why?
    (I used the following "workaround": comment those symbols in the pic18f452.h header file).

    Kind regards and best wishes for 2005,

    -- Edwin

    • SudFab

      Hi Edwin,

      The files needed to build the PIC16 lib are not included in all the Windows packages.

      You can find them in all the Linux packages, and use them in the Windows version of SDCC.

      Hope this help.


    • E. van Putten
      E. van Putten

      Thank you Fabien. I found them and it works. But only after I commented out a lot of "special" SFRs in the header file. Like PRODH, PCLATH, PCL etc. If you normally compile the libraries linker errors will occur when you link a simple 'hello world' like application.

      It seems that the compiler does not generate symbols in the object file (.o) for those special SFRs. That they are special SFRs must be the reason I guess but then, why are they included in the header file?

      Also I don't understand how I can produce the configuration bits for the PIC18F device from within a .C file. I know that it actually does produce configuration bits but in the hex file these look like "FF FF FF FF ..."  Which at least does not work with my PIC18F452.

      So I made a hack in my programmer and it will replace the configuration bits from SDCC with a valid configuration and put that in the chip.

      Made a few programs with SDCC that blink LEDs and TX bytes via the built in USART and other basic stuff. I was very surprised :-)

      At the moment I'm also figuring out how to do more "serious" things.  Like character pointers in an application (char *)...  I seem to be doing something wrong there because that doesn't work...

      -- Edwin

      • dwinkler

        Concerning configuration words... did you look for something like that:
        code char at __CONFIG1H config1h = 0xFF & _OSC_HS_1H;
        code char at __CONFIG2H config2h = 0xFF & _WDT_OFF_2H;
        code char at __CONFIG2L config2l = 0xFF & _PUT_ON_2L & _BODEN_OFF_2L;
        code char at __CONFIG4L config4l = 0xFF & _LVP_OFF_4L;

        Unfortunately some programmers complain, but it should work.

        Concerning pointers etc.:
        Try to keep your compiler in-sync with the CVS, maybe one or more problems are already fixed.

        If you still have problems, it might help to post sample code and your command line to the mailing list(s).

        JFYI: The libraries are not included as long as there are no gputils on the SF compile farm - otherwise the compile process there would be broken. Yes, it's also on our wishlist and maybe it will come one day ... stay tuned ... :-)

        Daniel Winkler