User forums > Embedded development

I created an CB wiki article about SDCC with PIC setup

<< < (2/2)

stahta01:
I added this to the simpleio.c file and it linked; I have no time to find the hardware to see if it created good code or not.


--- Code: ---// Define Port A
__sfr __at (0xF92) TRISA;
__sfr __at (0xF80) PORTA;
volatile __PORTAbits_t __at (0xf80) PORTAbits;

// Define Port B
__sfr __at (0xF93) TRISB;
__sfr __at (0xF81) PORTB;
volatile __PORTBbits_t __at (0xf81) PORTBbits;

--- End code ---

natescham:
This was an interesting read. I'm working on learning the PIC family and I'd like to try out Code Blocks myself instead of MPLAB.
Anyways, I'll let you know how it goes, being that I have several PIC development kits and all that.

Oh, and I'm a C programmer just so you know.
Well good luck with using C::B and the PIC.

freedomlives:
It seems there is something wrong with the current CB revision (as well as previous ones) or my understanding of how to configure CB for SDCC.  I just compiled from SVN 7075.

I get this error:

--- Code: ---sdcc -mpic16 -p18f2321  -I/usr/share/sdcc/non-free/include/pic16 -I/usr/share/sdcc/include/pic16 -I/home/andrew/projects/programming/Incubator/ -c Incubator.c -o obj/Release/Incubator.rel
INFO: changing configuration word at 0x300006 from 0xfb to 0xbb due to pic16devices.txt
sdcc -L/usr/share/sdcc/lib/pic16 -L/usr/share/sdcc/non-free/lib/pic16  -o bin/Release/Incubator -mpic16 -p18f2321     obj/Release/Incubator.rel
at 1: warning 119: don't know what to do with file 'obj/Release/Incubator.rel'. file extension unsupported
SDCC : pic16/pic14 3.0.0 #6037 (Nov  7 2010) (Linux)

--- End code ---

When I remove '-c' and '-o' from the first command, and add the '-L' paths and run the command in a terminal, I get the properly linked hex file and no errors. e.g.:
--- Code: ---sdcc -mpic16 -p18f2321 -I/usr/share/sdcc/non-free/include/pic16 -I/usr/share/sdcc/include/pic16  -I/home/andrew/projects/programming/Incubator/ -L/usr/share/sdcc/non-free/lib/pic16/ -L/usr/share/sdcc/lib/pic16/ Incubator.c
--- End code ---

The problem (I think) is that CB is trying to split compiling and linking into separate steps, while the sdcc can handle all of that at once.  I suspect that previous versions of SDCC would link the second command's *.rel files, but version 3.0.0 won't.  Anyway, I'm not quite sure how to fix the settings, but at least this might help someone else who is having this problem.

I used a modification of the code on the wiki, as shown below.  Pushbutton on RA4, LED on RB1, holding down PB turns on LED, releasing turns it off.


--- Code: ---#include <pic18f2321.h>
__code char __at __CONFIG1H conf2 = _OSC_INTIO2_1H;   // Internal Oscillator
__code char __at __CONFIG2H conf4 = _WDT_OFF_2H;                    // Disable WDT
__code char __at __CONFIG3H conf6 = _MCLRE_OFF_3H;
__code char __at __CONFIG4L conf7 = _LVP_OFF_4L;                    // Disable LVP

void main(){

// Initializing ports
    PORTA = 0;
    PORTB = 0;

    // Set RA4 as input and RB3-RB0 as output
    TRISA |= 0x10;
    TRISB &= 0xF0;

    // Set value 0x0A to PORTB
    PORTB = 0x0A;

    // While button is pressed, turn on RB1
    while(1) {
        if(PORTAbits.RA4 != 0){PORTBbits.RB1 = 1;}
        else PORTBbits.RB1 = 0;
    }
}


--- End code ---

squalyl:
The problem is extra simple.

In the past, sdcc used ".rel" for object files. SDCC 3.0 now uses ".o"

Just change this in the advanced compiler settings and all will go well.

Also don't forget --use-non-free for PIC compilation. No additional PATH is required with this option.

I guess it will be difficult for c::b to detect the SDCC version.

Navigation

[0] Message Index

[*] Previous page

Go to full version