I edited my code as your suggestion, but it still doesn't work.
My board is OK, because I write a small program in Assembly and
use ASM51 to generate HEX file, it works well.

------------------ led.asm ---------------------
$mod51  ; symbol definitions           

                org        00h
                ljmp    main
main:                          
                mov        p1,#0Fh      ; Turn on all led

                end
-------------------------------------------------

Regards

Nguyen.

-----Original Message-----
From: sdcc-user-admin@lists.sourceforge.net
[mailto:sdcc-user-admin@lists.sourceforge.net]On Behalf Of BRACH Vincent
Sent: Friday, February 03, 2006 6:13 PM
To: sdcc-user@lists.sourceforge.net
Subject: Re: [Sdcc-user] SDCC for AT89c52


On 51 base microcontroler on P1 and P3 port used as IO, you must write
(before writing your output value) one time on P1 or P3 to specifie the
direction of the IOs :

void main(void)
{
  P1 = 0x00 ; // all pin of P1 port are standard IO in output mode
  P1 = 0x0F ; // Led On on b7 to b4 on P1
  while (1) ;
}

(for current specification you MUST turn on LEDs on low level, high
level have'nt enough ouput current to turn on a LED)

____
    |     
    |     Vcc
    |      |
    |     _|_   
    |    _\_/_  LED
    |      |
  8 |      |
  9 |     | |   R
  c |     |_|
  5 |P1.4  |
  2 |-------            LED turn on with low level on P1.4
____|

++
Vinzzz


> Hi All
>
> I use SDCC to write program in C for AT89c52 at the first time.
> After compiling a simple program like this
>
> ------- led.c --------------------
> #include <at89x52.h>
> void main(void)
>         {
>         P1 = 0x0F;
>         while(1)
>         {}
>         }
> ----------------------------------
>
> c:\sdcc\mycode>sdcc led.c
>
> I get the file led.ihx
> Then I use "packihx < led.ihx > led.hex"
> to generate Intel Hex file.
>
> I use "EZ Uploader V3.0" to load led.hex to my chip AT89c52
> sucessfully.
> But the code don't work, All 8 LEDs on my board are off (4 of them
> must be on).
>
> I also try to load led.ihx to AT89C52 but It still doesn't work.
>
> Please tell me what I need to do to make my code work.
>
> Regards,
>
> Nguyen
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user