I just solved the problem, which comes from the
way I set the fuses of my pic. I have not yet totally
understand what was going wrong, and will have
a look at it tomorrow.

For now, I took a look at the gpdasm of the working
hex file generated by mc18 and used the configuration
values as follow:

#include <pic18fregs.h>


code char at __CONFIG1L _conf0 = 0x00;
code char at __CONFIG1H _conf1 = 0x0a;

code char at __CONFIG2L _conf2 = 0x00;
code char at __CONFIG2H _conf3 = 0x1e;

/* #define __CONFIG3L 0x300004 */
/* code char at __CONFIG3L _conf4 = 0x00; */
code char at __CONFIG3H _conf5 = 0x01;

code char at __CONFIG4L _conf6 = 0x81;
/* #define __CONFIG4H 0x300007 */
/* code char at __CONFIG4H _conf7 = 0x00; */

/* code char at __CONFIG5L _conf8 = 0x00; */
/* code char at __CONFIG5H _conf9 = 0x1e; */

/* code char at __CONFIG6L _confa = 0x81; */
/* code char at __CONFIG6H _confb = 0x00; */


void main(void)
{
  int i;
  long j;

  TRISA = 0;
  LATAbits.LATA0 = 0;

  i = 0;
   
  while (1)
    {
      LATAbits.LATA0 = i;
      i ^= 1;

      for (j = 0; j < 2000; ++j)
    ;
    }
}

I dont like this approach but it allows me to go forward with
open source tools.

Thanks for your help,

2008/11/26 lementec fabien <texane@gmail.com>
sorry, I didnot paste the right hex file.
here is the one:

:020000040000FA
:0400000015EF00F008
:06002A00F86AA68EA69CF8
:100030000F0EC16E070EB46E926A8980899200011C
:10004000626B0001636B23EF00F0010058000000B9
:0C00500060000000040000000000000040
:020000040030CA
:0E000000E03EF8E0FFFC9AFFFFFFFF9FFFFFCE
:00000001FF

generated from the following c code:

void _entry(void) __naked __interrupt 0;
void foo(void) __naked;



void _entry(void) __naked __interrupt 0
{
  __asm
    goto _foo
  __endasm ;
}


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

  __asm
    clrf    _TBLPTRU, 0
    bsf     0xa6, 7, 0
    bcf     0xa6, 6, 0
  __endasm;

  ADCON1 = 0x0f;
  CMCON = 7;

  TRISA = 0;

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

  j = 0;
 
  for (; ; )
    ;
}

Do you see anything else I could look at?

2008/11/26 lementec fabien <texane@gmail.com>

Thank you very much for helping, but the above
advices dont work.
Regarding the leds and the hw configuration I use,
I guess it works since flashing a HEX compiled with
the microchip mc18 compiler behaves correctly (ie.
leds are blinking).
I took a look at the HEX generated by sdcc, and it
is much more smaller than the one from mc tools, is
it something wrong with that?
Here are the contents:

:020000040000FA
:0400000080EF00F09D
:06002A00D9CFE5FFE1CF94
:10003000D9FF00C0E5FF01C0E5FF02C0E5FF03C036
:10004000E5FF04C0E5FF05C0E5FF06C0E5FF07C00A
:10005000E5FF020EDBCF00F0030EDBCF01F0040E54
:10006000DBCF02F0050EDBCF03F000C004F001C0CF
:1000700005F002C006F003C007F0FF0E0026FF0ED9
:100080000122FF0E0222FF0E03220450051006106B
:100090000710D8B462EF00F0FF0E046E056A066A1E
:1000A000076AFF0E0426FF0E0522FF0E0622FF0E32
:1000B00007220450051006100710D8A451EF00F0D5
:1000C00035EF00F0E4CF07F0E4CF06F0E4CF05F021
:1000D000E4CF04F0E4CF03F0E4CF02F0E4CF01F08A
:1000E000E4CF00F0E4CFD9FF12000F0EC16E070E6F
:1000F000B46E92909292809080827DEF00F0120018
:1001000012EE3FF022EE3FF0F86AA68EA69C75EC48
:0401100000F0FFD725
:020000040030CA
:0E000000E03EF8E0FFFC9AFFFFFFFF9FFFFFCE
:00000001FF

I really appreciate your help, I want to use an open source
compilation suite for learning pic programming, and not
install wine + mc tools... doing so would not help in testing
and improving sdcc.

Thanks,

2008/11/26 Vaclav Peroutka <vaclavpe@seznam.cz>

If it did not help, you have problem somewhere else. Check following:
- correct voltage on PIC
- if LED is correctly polarized
- do you use blocking capacitor on PIC's power pins ?
- do you have oscilaltor correctly set (try internal OSC)

About month ago I had problem with unstable UART. It was because I used too low voltage and highest speed. PIC did not supported it.

V.

> ------------ Původní zpráva ------------
> Od: lementec fabien <texane@gmail.com>
> Předmět: Re: [Sdcc-user] [ pic18f, simple program, no crt ]
> Datum: 25.11.2008 20:24:16
> ----------------------------------------
> Hi,
>
> Thanks foro you help but it didnot make the program
> work. I use the following to compile the single file program:
>
> sdcc -mpic16 -p18f4550 -D_SDCC -Dpic18f4550 --no-crt main.c
>
> Any suggestion?
>
> Thanks for helping,
>
> On Mon, Nov 24, 2008 at 6:25 PM, Raphael Neider <rneider@web.de> wrote:
>
> > > I am trying to make the following code
> > > work when compiled by sdcc for pic18f4550
> > > with --no-crt.
> > >
> > > I take care not using stack, but I guess thi is
> > > not  a problem given the way sdcc works.
> > >
> > > It compiles, but at run time my led is not switched
> > > on (the led works well)
> > >
> > > Could you tell me if there is something wrong with
> > > the code?
> >
> > You need to add
> >
> > #include <pic18fregs.h>
> > __code char __at(__CONFIG4L) __conf4l = _ENHCPU_OFF_4L;
> >
> > at the top of your code to disable the extended instruction set.
> >
> > Hope that helps,
> > Raphael
> >
> > -------------------------------------------------------------------------
> > 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
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> > _______________________________________________
> > Sdcc-user mailing list
> > Sdcc-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/sdcc-user
> >
>
>
>

-------------------------------------------------------------------------
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
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user