From: BRACH V. <v....@sm...> - 2006-02-06 09:38:29
|
Hi Nguyen, Personnaly, I use sdcc version 2.5.0 (May 8 2005) (UNIX) (current stable version) 2.3 is an old version. Start by update your sdcc and try again ;). maybe it's your problem but I don't think so (read the "Past news" chapter on http://sdcc.sourceforge.net/) Regards, Vinzzz > I'm using SDCC version: mcs51 2.3.1-pj3 (Jan 20 2002) (MINGW). > I'm a newbie in SDCC, I don't know which is a good verion of SDCC. > Please show me this. > > Regards > > Nguyen > > -----Original Message----- > From: sdc...@li... > [mailto:sdc...@li...]On Behalf Of Maarten > Brock > Sent: Saturday, February 04, 2006 10:15 PM > To: sdc...@li... > Subject: RE: [Sdcc-user] SDCC for AT89c52 > > > The shown code raises the suspicion that you're using an old version > of SDCC. Please state which version. > > Is the AT89c52 equipped with a watchdog that is on by default? How > much internal RAM does it have and are sfr's direct addressable only? > > If you do not supply your own version of _sdcc_program_startup > the one in _startup.c is used. > > > I think that there is some problems with SDCC startup code. > > Now I can make my code work with this procedure > > > > step1> sdcc -c led.c (only generate led.asm) > > step2> I edit led.asm. At address 0000 of CSEG, I don't let SDCC > jump to > > "__sdcc_gsinit_startup" but I let SDCC jump directly to "_main" > > step3> asx8051 -o led.asm > > step4> sdcc led.rel > > step5> packihx <led.ihx> led.hex > > step6> load led.hex to AT89c52 > > > > And it works. > > > > I wonder if there is any problem with SDCC startup code. I copy it > here > > > > *********************************** led.asm > > **************************************************************** > > ;-------------------------------------------------------- > > ; internal ram data > > ;-------------------------------------------------------- > > .area DSEG (DATA) > > ;-------------------------------------------------------- > > ; overlayable items in internal ram > > ;-------------------------------------------------------- > > .area OSEG (OVR,DATA) > > ;-------------------------------------------------------- > > ; Stack segment in internal ram > > ;-------------------------------------------------------- > > .area SSEG (DATA) > > __start__stack: > > .ds 1 > > > > ;-------------------------------------------------------- > > ; indirectly addressable internal ram data > > ;-------------------------------------------------------- > > .area ISEG (DATA) > > ;-------------------------------------------------------- > > ; bit data > > ;-------------------------------------------------------- > > .area BSEG (BIT) > > ;-------------------------------------------------------- > > ; external ram data > > ;-------------------------------------------------------- > > .area XSEG (XDATA) > > ;-------------------------------------------------------- > > ; external initialized ram data > > ;-------------------------------------------------------- > > .area XISEG (XDATA) > > ;-------------------------------------------------------- > > ; interrupt vector > > ;-------------------------------------------------------- > > .area CSEG (CODE) > > __interrupt_vect: > > ljmp __sdcc_gsinit_startup > > reti > > .ds 7 > > reti > > .ds 7 > > reti > > .ds 7 > > reti > > .ds 7 > > reti > > .ds 7 > > reti > > .ds 7 > > ;-------------------------------------------------------- > > ; global & static initialisations > > ;-------------------------------------------------------- > > .area GSINIT (CODE) > > .area GSFINAL (CODE) > > .area GSINIT (CODE) > > __sdcc_gsinit_startup: > > mov sp,#7 > > lcall __sdcc_external_startup > > mov a,dpl > > jz __sdcc_init_data > > ljmp __sdcc_program_startup > > __sdcc_init_data: > > ; _mcs51_genXINIT() start > > mov a,#l_XINIT > > orl a,#l_XINIT>>8 > > jz 00003$ > > mov a,#s_XINIT > > add a,#l_XINIT > > mov r1,a > > mov a,#s_XINIT>>8 > > addc a,#l_XINIT>>8 > > mov r2,a > > mov dptr,#s_XINIT > > mov r0,#s_XISEG > > mov p2,#(s_XISEG >> 8) > > 00001$: clr a > > movc a,@a+dptr > > movx @r0,a > > inc dptr > > inc r0 > > cjne r0,#0,00002$ > > inc p2 > > 00002$: mov a,dpl > > cjne a,ar1,00001$ > > mov a,dph > > cjne a,ar2,00001$ > > mov p2,#0xFF > > 00003$: > > ; _mcs51_genXINIT() end > > .area GSFINAL (CODE) > > ljmp __sdcc_program_startup > > ;-------------------------------------------------------- > > ; Home > > ;-------------------------------------------------------- > > .area HOME (CODE) > > .area CSEG (CODE) > > ;-------------------------------------------------------- > > ; code > > ;-------------------------------------------------------- > > .area CSEG (CODE) > > __sdcc_program_startup: > > lcall _main > > ; return from main will lock up > > sjmp . > > ;------------------------------------------------------------ > > ;Allocation info for local variables in function 'main' > > ;------------------------------------------------------------ > > ; led1.c 3 > > ; ----------------------------------------- > > ; function main > > ; ----------------------------------------- > > _main: > > ar2 = 0x02 > > ar3 = 0x03 > > ar4 = 0x04 > > ar5 = 0x05 > > ar6 = 0x06 > > ar7 = 0x07 > > ar0 = 0x00 > > ar1 = 0x01 > > ; led1.c 5 > > ; genAssign > > mov _P1,#0x00 > > ; led1.c 7 > > ; genAssign > > clr _P1_0 > > ; led1.c 8 > > ; genAssign > > clr _P1_1 > > ; led1.c 9 > > ; genAssign > > setb _P1_2 > > ; led1.c 10 > > ; genAssign > > clr _P1_3 > > ; led1.c 11 > > ; genAssign > > setb _P1_4 > > ; led1.c 12 > > ; genAssign > > clr _P1_5 > > ; led1.c 13 > > ; genAssign > > setb _P1_6 > > ; led1.c 14 > > ; genAssign > > clr _P1_7 > > ; led1.c 16 > > 00102$: > > ; Peephole 132 changed ljmp to sjmp > > sjmp 00102$ > > 00104$: > > ret > > .area CSEG (CODE) > > .area XINIT (CODE) > > > **************************************************************************** > > ************************************ > > > > > > > > -----Original Message----- > > From: sdc...@li... > > [mailto:sdc...@li...]On Behalf Of BRACH > Vincent > > Sent: Friday, February 03, 2006 9:02 PM > > To: sdc...@li... > > Subject: RE: [Sdcc-user] SDCC for AT89c52 > > > > > > 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... > > <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 > > > <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642> > > &kid=103432&bid=230486&dat=121642 > > _______________________________________________ > > Sdcc-user mailing list > > Sdc...@li... > > https://lists.sourceforge.net/lists/listinfo/sdcc-user > > <https://lists.sourceforge.net/lists/listinfo/sdcc-user> > > > > > > > > > > > > > ------------------------------------------------------- > 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 > |