#include "p18f452.h"
int count;
void main(void) {
TRISA = 0;
count = 0;
while(1) {
PORTA = count;
count ++;
}
}
Building: /tmp/kde-root/ktechlabbvnDNa.hex
sdcc --debug -S -mpic16 -p18f452 /usr/local/share/sdcc/include/pic16/count.c -o /tmp/kde-root/ktechlab9I4MEb.asm
Processor: 18f452
/usr/local/share/sdcc/include/pic16/count.c:1:21:
p18f452.h: No such file or directory
/usr/local/share/sdcc/include/pic16/count.c:7: error 20: Undefined identifier 'TRISA'
/usr/local/share/sdcc/include/pic16/count.c:10: error 20: Undefined identifier 'PORTA'
-:0: error 103: code not generated for 'main' due to previous errors
*** Compilation failed ***
#include "p18f452.h"
int count;
void main(void) {
TRISA = 0;
count = 0;
while(1) {
PORTA = count;
count ++;
}
}
sdcc -mpic16 -p18f452 -V --debug -I/usr/local/share/sdcc/include/pic16/ -c count.c
Processor: 18f452
count.c:1: p18f452.h: No such file or directory
count.c:7: Undefined identifier 'TRISA'
count.c:10: Undefined identifier 'PORTA'
code not generated for 'main' due to previous errors
+ "/usr/local/bin/sdcpp" -nostdinc -Wall -std=c99 -DSDCC=1 -I"/usr/local/share/sdcc/include/pic16/" -Dpic18f452 -D__18f452 -DSTACK_MODEL_SMALL -DSDCC_MODEL_SMALL -DSDCC_pic16 -D__pic16 -I"/usr/local/bin/../share/sdcc/include/pic16" -I"/usr/local/share/sdcc/include/pic16" -I"/usr/local/share/sdcc/include/pic16/" "count.c"
*** Exited with status: 1 ***
Building: /tmp/kde-root/ktechlabUqsYIb.hex
sdcc --debug -S -mpic16 -p18f452 /usr/local/share/sdcc/include/pic16/count.c -o /tmp/kde-root/ktechlabsJiLXa.asm
Processor: 18f452
*** Compilation successful ***
gpasm --object --output /tmp/kde-root/ktechlabVHQWga.o --hex-format inhx32 --warning 0 --ignore-case --force-list /tmp/kde-root/ktechlabsJiLXa.asm
/tmp/kde-root/ktechlabsJiLXa.asm:10:Warning [230] directive ignored when debug info is disabled
/tmp/kde-root/ktechlabsJiLXa.asm:188:Warning [230] directive ignored when debug info is disabled
/tmp/kde-root/ktechlabsJiLXa.asm:191:Warning [230] directive ignored when debug info is disabled
/tmp/kde-root/ktechlabsJiLXa.asm:197:Warning [230] directive ignored when debug info is disabled
/tmp/kde-root/ktechlabsJiLXa.asm:201:Warning [230] directive ignored when debug info is disabled
*** Assembly successful ***
gplink --hex-format inhx32 --map --output /tmp/kde-root/ktechlabUqsYIb.hex /tmp/kde-root/ktechlabVHQWga.o
message: using default linker script "/usr/share/gputils/lkr/18f452.lkr"
error: missing definition for symbol "_PORTA", required by "/tmp/kde-root/ktechlabVHQWga.o"
error: missing definition for symbol "_TRISA", required by "/tmp/kde-root/ktechlabVHQWga.o"
*** Linking failed ***
sdcc -mpic16 -p18f452 -V --debug -I/usr/local/share/sdcc/include/ -c pic16/count.c
Processor: 18f452
+ "/usr/local/bin/sdcpp" -nostdinc -Wall -std=c99 -DSDCC=1 -I"/usr/local/share/sdcc/include/" -Dpic18f452 -D__18f452 -DSTACK_MODEL_SMALL -DSDCC_MODEL_SMALL -DSDCC_pic16 -D__pic16 -I"/usr/local/bin/../share/sdcc/include/pic16" -I"/usr/local/share/sdcc/include/pic16" -I"/usr/local/share/sdcc/include/" "pic16/count.c"
+ "gpasm" -DSDCC_MODEL_SMALL -Dpic18f452 -D__18F452 -DSTACK_MODEL_SMALL -g -c "count.asm" -o "count.o"
sdcc -mpic16 -p18f452 -V --debug -Wl-c -o count.hex pic16/count.o
Processor: 18f452
crt0i.o: No such file or directory
+ "gplink" -I"/usr/local/bin/../share/sdcc/lib/pic16" -I"/usr/local/share/sdcc/lib/pic16" -c -o count crt0i.o pic16/count.o pic18f452.lib libsdcc.lib
*** Exited with status: 1 ***
/****************************************************************************/
/* delay0.h Junio-2004 */
/*---------------------------------------------------------------------------*/
/* Ejemplo para el skybot */
/*---------------------------------------------------------------------------*/
/* Este fichero esta pensado para ser incluido en el programa principal. */
/* Antes de utilizar la funcion delay0() es necesario llamar a */
/* timer0_configurar() para configurar correctamente el timer 0 */
/*---------------------------------------------------------------------------*/
/* Utilizacion del temporizador 0 para generar una pausa de 10ms y */
/* obtener una rutina de delay en unidades de 10ms */
/* No se utilizan interrupciones */
/* El temporizador 0 es de 8 bits */
/*---------------------------------------------------------------------------*/
/* Andres Prieto-Moreno <andres@ifara.com> */
/* Juan Gonzalez <juan@iearobotics.com> */
/*---------------------------------------------------------------------------*/
/* LICENCIA GPL */
/*****************************************************************************/
//-- Definiciones
#define TICKS10 0x3D // Valor con el que inicializar contador para
// conseguir TICKs de 10ms
/************************************/
/* Configurar el temporizador 0 */
/************************************/
void timer0_configurar()
{
//-- Usarlo en modo temporizador, prescaler = 256
OPTION_REG=0x87;
}
/************************************************/
/* Hacer una pausa en unidades de 10ms */
/* ENTRADA: */
/* -pausa: Valor de la pausa en decenas de ms */
/************************************************/
void delay0(unsigned char pausa)
{
//-- Esperar hasta que trancurran pausa ticks de reloj
while(pausa>0) {
TMR0=TICKS10; // Inicializar contador
T0IF=0; // Quitar flag overflow
//-- Esperar hasta que bit T0IF se ponga a '1'. Esto
//-- indica que han transcurrido 10ms
while (!T0IF);
//-- Ha transcurrido un tick
pausa--;
}
}
Ejemplos y librerías para SDCC:
general:
http://sdccokr.dl9sec.de/resources.htm
PIC:
ejemplos básicos: http://datrus.com/qwikflash-howto.tgz de esta página: http://datrus.com/qwikflash-howto.html
librería + ejemplo LCD 16x2 con PIC18F252: http://www.warpedlogic.co.uk/?q=node/10
libreria + ejemplo para I2C con PIC18F2550 (master): http://www.pic-o-rama.org/images/stories/projects/i2c_master/i2c_master.tar.gz
libreria + ejemplo para I2C con PIC18F2550 (slave): http://www.pic-o-rama.org/images/stories/projects/i2c_slave/i2c_slave.tar.gz
Ejemplo Usart con PIC18F2550: http://my.opera.com/raphman/blog/show.dml/266030
Varias librerías y ejemplos para I2C, uart, lcd, delays y más... para PIC16F877: http://per.launay.free.fr/pik_digor/sdcc/
El SDCC ha avanzado mucho desde que se inició este post, y ultimamente parece que va a muy buen ritmo, soporte para muchos PICs y ejemplos y librerías disponibles.
Saludos.
Código
GeSHi (c):
16.
while(1) {
17.
PORTA = count;
18.
count ++;
19.
delay1mtcy("1");
20.
}
21.
22.
}
y los horrores... perdón los errores: