True's beaked whale.jpg

Western spotted skunk

Hooded skunk

Yellow-throated Marten

Wolverine

Compiling for pic18 using sdcc

Upgraded to sdcc 3.2.0 from 2.9.0, and gputils to 1.0.0. The build commands I was using didn’t work, chnages to the .c file and build commands were needed:

Changes to the .c file:
Drop:

__code char __at(__CONFIG1H) __conf1h = _OSC_INTIO67_1H;
__code char __at(__CONFIG2H) __conf2h = _WDT_OFF_2H; //out for p18f4620
__code char __at(__CONFIG2L) __conf2l = _PWRT_OFF_2L & _BOREN_OFF_2L;
__code char __at(__CONFIG3H) __conf3h = _MCLRE_OFF_3H & _PBADEN_OFF_3H; //out for p18f4620
__code char __at(__CONFIG4L) __conf4l = _XINST_OFF_4L & _DEBUG_OFF_4L & _LVP_ON_4L;

Add:

#include "pic18f46k20.h"
#pragma config FOSC=INTIO67, BOREN=OFF, PWRT=OFF, MCLRE=OFF, PBADEN=OFF, XINST=OFF, DEBUG=OFF, LVP=ON, WDTEN=OFF
//Instead of WDT=OFF, see the .inc file
//Instead of OSC, use FOSC, see the .inc file

The CONFIG settings in /usr/local/share/sdcc/non-free/include/pic16/pic18f46k20.h and /usr/local/share/gputils/header/p18f46k20.inc do not match. WDT changes to WDTEN, OSC to FOSC

Command to compile:

/usr/local/bin/sdcc -V -mpic16 --use-non-free -p18f46k20 -c p18_step_control.c -Wl"-s ./18f46k20.lkr"

Leave a Reply