Thank you for your answer, seems there
was a little race condition  while mailing :)
Btw you were right regarding the configuration
bits. The code I posted did not intend to make
the led blink, just switch one on, for the sake
of shortness.

I use a very daily snap of sdcc, and the latest
versions of gputils and pk2cmd both rebuilt
from source.

Thank you for helping, and if you have anything
(links, forums threads ...) related to the pic18f
programming with the openource toolsuite, they
are welcome.

Have  a good day,

On Thu, Nov 27, 2008 at 1:09 AM, Raphael Neider <rneider@web.de> wrote:

void foo (void) __naked
 static int i = 0;
 static int j = 0;

   clrf    _TBLPTRU, 0
   bsf     0xa6, 7, 0
   bcf     0xa6, 6, 0

 ADCON1 = 0x0f;
 CMCON = 7;

 TRISA = 0;

 LATAbits.LATA0 = 1;
 LATAbits.LATA1 = 0;

 j = 0;

 for (; ; )

This code would not blink any LED, just turn it on (or off) if its connected to PORTA<0> or PORTA<1>.
Additionally, you did not post your whole main.c; at least the line
#include <pic18fregs.h> // or #include <pic18f4550.h>
is missing, without which the file does not compile.

Do you see anything else I could look at?

Do you need any config bits setup correctly, e.g, oscillator source and speed? Disable the watchdog timer.

The larger hex-file (from mc18?) you provided has

:0E000000 E0 3E F8 E0 FF FC 9A FF FF FF FF 9F FF FF CE

CONFIG1L 0xE0 (4 MHz oscillator, 48 MHz system clock)
CONFIG1H 0x3E (HSPLL-mode)
CONFIG2L 0xF8 (USB VREG enabled, BOR disabled, PWRT enabled)
CONFIG2H 0xE0 (WDT disabled)
CONFIG3L 0xFF (unimplemented)
CONFIG3H 0xFC (MCLR enabled, PORTB<4:0> analog inputs)
CONFIG4H 0xFF (unimplemented)
CONFIG5L 0xFF (no code protection)
CONFIG5H 0xFF (no code protection)
CONFIG6L 0xFF (no write protection)
CONFIG6H 0x9F (ARGH, boot-block and config bits are write-protected)
CONFIG7L 0xFF (no protection against TBLRD)
CONFIG7H 0xFF (no protection against TBLRD)

Due to CONFIG6H, you may have to bulk erase your device before programming it with SDCC's hex-file.

Try blinky using SDCC's startup code (see attachment). This one toggles all PORTA-pins using them as a binary counter. You may want to attach more than only LED to the pins ...

Compile with
sdcc -mpic16 -p18f4550 blinky.c

Possibly use the config values from above (esp. CONFIG1L, 1H, 2L, 2H, and 4L). See attached file on how to do so using SDCC.

The delay-loop (over 'i') might be too short for HSPLL mode, increase the final count from 200 to 2000, or even 20000.
You should see the LED light up constantly abount half-bright even with the supplied code, though.

Update your compiler from a daily snapshot, what's your current version (output of sdcc -v)? Mine is
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.8.5 #5275 (Nov 25 2008) (UNIX)

Good luck,
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
Sdcc-user mailing list