From: BRACH V. <v....@sm...> - 2006-02-03 14:02:17
|
Hum, it's curious in ASM it worked well (without two write for P1 to indicate the IO port direction) and in C did'nt work :( It could be no startup code (??) What's you compilation lines options ? Personally I compil with Makefile in two time (I'm working on linux station with large-model compilation): 1/ Compiling : /usr/local/bin/sdcc -c -mmcs51 --debug --model-large --debug --no-xinit-opt --opt-code-size -I/usr/local/share/sdcc/include main.c ... ... other C modules 2/ Linking and packihx : /usr/local/bin/sdcc --model-large --out-fmt-ihx --code-loc 0x0000 --code-size 0xFFFF --data-loc 0x00 --idata-loc 0x80 --iram-size 0x100 --xram-loc 0x0001 --xram-size 0x7FF --debug --no-xinit-opt --opt-code-size -L/usr/local/share/sdcc/lib main.rel and /usr/local/bin/packihx main.ihx > main.hex In fact, all C files compiling generate .rel files, and linking step link all .rel file (with main in first if you've got multiple modules) In windows I think you could try : c:\sdcc\mycode>sdcc -c -mmcs51 --model-small led.c check at this point your asm code in .lst file gerenated. c:\sdcc\mycode>sdcc --model-small --out-fmt-ihx --code-loc 0x0000 --code-size 0xFFFF --data-loc 0x00 --idata-loc 0x80 --iram-size 0x100 led.rel c:\sdcc\mycode>packihx led.ihx > led.hex Nota : lots of compil and link options are indicated but not necessary (default option), but I find more explicit to view them. Check your first line in your .hex file : for example :06 00 00 00 02 C3 63 02 07 E3 E6 At adress 0x0000 (start vector) you must have 02 (jump) C363 your start code (for example) At this time you'll sure your program well jump at startup code. Regards, Vinzzz > > 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: sdc...@li... > [mailto:sdc...@li...]On Behalf Of BRACH > Vincent > Sent: Friday, February 03, 2006 6:13 PM > To: sdc...@li... > 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 > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > |