Author Topic: I created an CB wiki article about SDCC with PIC setup  (Read 19213 times)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6546
    • My Best Post
I created an CB wiki article about SDCC with PIC setup
« on: May 07, 2008, 11:04:12 pm »
See
http://wiki.codeblocks.org/index.php?title=Using_the_Code::Blocks_IDE_with_SDCC_on_PIC_MCUs

Please use this thread for questions on the wiki article.
If you can add info to the wiki article please feel free to add it.

Tim S

« Last Edit: May 08, 2008, 01:12:01 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: I created an CB wiki article about SDCC with PIC setup
« Reply #1 on: May 08, 2008, 06:54:48 am »
This is really interesting, I'm looking to learn some embedded programming and how I can make some revenue with it, since I'm running my own business now (really hardcore, need to get moving). I'm willing to learn what I can do with this stuff, with codeblocks guiding me  :D

The problem is I don't know which board/chip I should buy, There is the avr (really popular) but men do I will need to learn some electronics too :?:, I took a course of electronics but that was some years ago, I need a mind refresh :P

For now web pages are not getting me anywhere neither custom applications programming, I need some guidance from others experiencing the situation that I'm experiencing (running your own business) or something similar  :?

Should I become an open source consultant and evangelize developers with codeblocks  :lol:

Offline haytick

  • Single posting newcomer
  • *
  • Posts: 2
Re: I created an CB wiki article about SDCC with PIC setup
« Reply #2 on: December 09, 2010, 03:37:50 am »
i try to follow your instruction,
and there is some differences,
and when i compile the code you wrote,
the compiler show error because the header files is not exist.

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: I created an CB wiki article about SDCC with PIC setup
« Reply #3 on: December 09, 2010, 12:00:30 pm »

Have u notified codeblocks of ur header paths? Express some detail pls.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6546
    • My Best Post
Re: I created an CB wiki article about SDCC with PIC setup
« Reply #4 on: December 10, 2010, 06:04:48 pm »
Added following to wiki page needed for SDCC 3.0.0; header moved for licensing reason.

Tim S.

Code: [Select]
PIC Normal Compiler search directory for SDCC 3.0 and later of "C:\Program Files\SDCC\non-free\include"
Edit: I can not yet get SDCC 3.0.0 to link. I am not likely to have time to work on this till Final Week is over.

I am looking at http://sourceforge.net/apps/trac/sdcc/wiki/SDCC_tutorial for more info.
« Last Edit: December 11, 2010, 01:48:02 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6546
    • My Best Post
Re: I created an CB wiki article about SDCC with PIC setup
« Reply #5 on: December 11, 2010, 03:35:45 am »
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: [Select]
// 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;
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline natescham

  • Single posting newcomer
  • *
  • Posts: 8
Re: I created an CB wiki article about SDCC with PIC setup
« Reply #6 on: December 21, 2010, 09:14:14 pm »
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

  • Guest
Re: I created an CB wiki article about SDCC with PIC setup
« Reply #7 on: April 01, 2011, 10:12:17 pm »
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: [Select]
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)

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: [Select]
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
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: [Select]
#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;
    }
}


Offline squalyl

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: I created an CB wiki article about SDCC with PIC setup
« Reply #8 on: April 04, 2011, 10:00:25 am »
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.