I'm currently trying to use SDCC to generate an Intel Hex file for a PIC16
device (pic18f452). I'm using a Makefile and multiple source files, to be
compiled separately and linked at the end. This is my Makefile setup:

CFLAGS=--std-c99 --use-non-free -mpic16
LDFLAGS=--out-fmt-ihx

build/image.hex: build/main.rel build/lcd.rel
sdcc -o build/image.hex $^

build/main.rel: main.c lcd.h
sdcc $(CFLAGS) -c $< -o $@

build/lcd.rel: lcd.c lcd.h
sdcc $(CFLAGS) -c $< -o $@

The source files are as simple as it gets:

*lcd.h:*
#ifndef _LCD_H_
#define _LCD_H_

void lcd_init(void);

#endif

*lcd.c:*
#include <pic16/pic18f452.h>
#include "lcd.h"

void lcd_init(void) {
PORTEbits.RE1 = 0;
PORTEbits.RE2 = 0;
}

*main.c:*
#include <pic16/pic18f452.h>
#include "lcd.h"

void main() {
lcd_init();

while (1);
}

Running make gives me the following (warnings?) errors, from the linking
stage:
ASlink-Warning-No definition of area HOME
ASlink-Warning-No definition of area XSEG
ASlink-Warning-No definition of area PSEG

And I don't get my output. If I concatenate all my code into one file
and run sdcc on it, however, it works:

$ cat lcd.h lcd.c main.c > *monster.c*
$ sdcc --use-non-free -mpic16 monster.c
message: Using default linker script "/usr/share/gputils/lkr/18f452_g.lkr".

$ ls
lcd.c  lcd.h  main.c  Makefile monster.asm  monster.c  monster.cod
*monster.hex*  monster.lst  monster.o

Is there some other setup I should be doing, or flag I should be passing?
I'm not really using any ASM code or defining my own areas, and expected it
to work out-of-the-box with C. Are my assumptions wrong?

Sorry for the long message, hope to hear soon
Thanks in advance,
    Délisson J. G. Silva
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to