Author Topic: Compiler SDCC: how do you change the pic-processor type ?  (Read 13913 times)

Offline eckard_klotz

  • Almost regular
  • **
  • Posts: 198
Compiler SDCC: how do you change the pic-processor type ?
« on: March 08, 2007, 05:45:36 am »
Hello everyone.

I'm using the C::B nightly-build from 1’st of March 2007 under WINXP to write a program for a microchip PIC18F458. I use the SDCC as compiler together with the gputils.

How do I configure the processor-type? Currently C::B (or SDCC) uses the header-files for the PIC18F452, so some registers are not defined correctly. The only way I found to change it, is to edit the SDCC-header named "pic18fregs.h" like this:

Code
...
#elif defined(pic18f452)
//#  include <pic18f452.h>
#  include <pic18f458.h> /*changed by Eckard Klotz*/
...

But this is not the way I would prefer. I think, I have overseen something, so where is my failure?


A second point is how to use the MPLAB-tools instead of the gputils. Is there also a possibility to configure it, which I have overseen?

best regards,
                  Eckard Klotz.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Compiler SDCC: how do you change the pic-processor type ?
« Reply #1 on: March 08, 2007, 09:15:16 am »
You should better ask those tools' authors for answers. They have nothing to do with C::B itself and most probably no one can help you here.
Be patient!
This bug will be fixed soon...

Offline eckard_klotz

  • Almost regular
  • **
  • Posts: 198
Re: Compiler SDCC: how do you change the pic-processor type ?
« Reply #2 on: March 09, 2007, 06:58:13 am »
Hello everyone.

Quote
You should better ask those tools' authors for answers. They have nothing to do with C::B itself and most probably no one can help you here.

OK, I've done this and here is the answer:

1. To define the processor-type there is the p-option which has to be added in the "other options"-tab of the build-options like this:
                        -p18f458

2. The SDCC does not call the assembler-tool (gpasm or mplab) by itself. This has to be done in the make-file like in this examples (copied out of the manuel of the SDCC):

Quote
Here is a Makefile using GPUTILS:

.c.o:
   sdcc -S -V -mpic14 -p16F877 $<
   gpasm -c $*.asm
$(PRJ).hex: $(OBJS)
   gplink -m -s $(PRJ).lkr -o $(PRJ).hex $(OBJS) libsdcc.lib


Here is a Makefile using MPLAB:

.c.o:
   sdcc -S -V -mpic14 -p16F877 $<
   mpasmwin /q /o $*.asm
$(PRJ).hex: $(OBJS)
   mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib


If I compilewith the SDCC I get the asm-files (what means the SDCC is working) but I get no hex-file. In the build log I found the following message:

Quote
sdcc.exe --out-fmt-ihx -mpic16 -Wall -p18f458 -D__18F458 --out-fmt-ihx -mpic16 --verbose --debug -Wall -p18f458 --out-fmt-ihx -mpic16  -I..\..\..\H -I..\..\..\Def -IC:\sdcc\include -IC:\include  -c ..\..\..\C\xxx.C -o obj\Release\C\xxx.rel
Usage: gpasm [options] file
Options: [defaults in brackets after descriptions]
  -a FMT, --hex-format FMT       Select hex file format. [inhx32]
  -c, --object                   Output relocatable object.
  -d, --debug                    Output debug messages.
  -D SYM=VAL, --define SYM=VAL   Define SYM with value VAL.
  -e [ON|OFF], --expand [ON|OFF] Macro expansion.
  -g, --debug-info               Use debug directives for COFF.
  -h, --help                     Show this usage message.
  -i, --ignore-case              Case insensitive.
  -I DIR, --include DIR          Specify include directory.
  -l, --list-chips               List supported processors.
  -L, --force-list               Ignore nolist directives.
  -m, --dump                     Memory dump.
  -M, --deps                     Output dependency file.
  -o FILE, --output FILE         Alternate name of output file.
  -p PROC, --processor PROC      Select processor.
  -q, --quiet                    Quiet.
  -r RADIX, --radix RADIX        Select radix. [hex]
  -u, --absolute                 Use absolute pathes.
  -v, --version                  Show version.
  -w [0|1|2], --warning [0|1|2]  Set message level.

  -y, --extended                 Enable 18xx extended mode.
Default header file path D:\Tools\gputils\header
Report bugs to:
<URL:http://gputils.sourceforge.net/>

Processor: 18f458
sdcc: Calling preprocessor...
sdcc: Generating code...
sdcc: Calling assembler...

I think the point is, that there are some wrong or old options in the default make-file. So how can I change it or where have I do to ask?

Kind regards,
                  Eckard Klotz