Program no longer compiling (PIC18F4520)

Help
2010-11-27
2013-03-12
  • Thomas Preston
    Thomas Preston
    2010-11-27

    After a recent update to sdcc my programs no longer compile when using:

    $ sdcc -mpic16 -p18f4520 readSwitches.c
    readSwitches.c:5:30: error: pic16/pic18f4520.h: No such file or directory
    readSwitches.c:10: error 20: Undefined identifier 'PORTC'
    readSwitches.c:11: error 20: Undefined identifier 'PORTA'
    readSwitches.c:18: error 20: Undefined identifier 'TRISD'
    readSwitches.c:19: error 20: Undefined identifier 'ADCON1'
    readSwitches.c:22: error 20: Undefined identifier 'LATD'
    

    This used to compile correctly before the update:

    /* #: Description : Counts up in binary on LED's
       #: Author      : Thomas Preston
    */
    #include "pic18f4520.h"
    unsigned char readSwitches(void)
    {
      char mostSigBits = (PORTC & 0x0F) << 4;
      char leastSigBits = PORTA & 0x0F;
      
      return mostSigBits | leastSigBits;
    }
    void main (void)
    {
      TRISD = 0;
      ADCON1 = 0x0F; // Configures portA to be digital and not analogue
      
      while(1)
        LATD = readSwitches();
    }
    

    Also, if I give the absolute location of the header file I get:

    $ sdcc -mpic16 -p18f4520 readSwitches.c
    libdev18f4520.lib: No such file or directory
    

    Has something changed? I noticed a new directory 'non-free' but I can't remember if that was always there or not.

     
  • Thomas Preston
    Thomas Preston
    2010-11-27

    Absolute location is: /usr/share/sdcc/non-free/include/pic16/pic18f4520.h

     
  • Raphael Neider
    Raphael Neider
    2010-11-27

    Due to unresolved licensing issues with the PIC device headers and libraries, we moved them to non-free-subdirectories and add appropriate search patch (-I and -L) only when the new command-line switch -use-non-free is specified when compiling / linking via sdcc.

    You *should* be fine if you
    #include "pic18f4520"
    and add
    -use-non-free
    to the sdcc command line.

     
  • Raphael Neider
    Raphael Neider
    2010-11-27

    Well, make that
    #include "pic18f4520.h"

     
  • Thomas Preston
    Thomas Preston
    2010-11-27

    That works great. Thanks!

    Also, how would I have found that out without of coming here? Is there a change log detailing such things?