Can anyone help with how you successfully run SDCC on a Windows XP machine and generate proper hex files?
I am starting on a project using an Atmel AT89C5131 (an 8051 derivative with a built-in USB port). I have written several small test programs in assembler and they run just fine. But all attempts to run any small test program written using the SDCC C compiler have resulted in failure. Obviously I am doing something wrong, but have no clue what.
For example, the following simple assembler program:
; Assembler code - LED Test LEDCON DATA 091H ;LED control register P1_5 BIT 095H ;P1.5 - pushbutton switch P3_7 BIT 0B7H ;P3.7 - status LED ORG 00000H ORL LEDCON, #0C0H ; Set P3.7 for 10mA LED current limit LOOP: JNB P1_5, PB_PRESSED ; Read status of pushbutton switch SETB P3_7 ; Turn LED off (set P3.7 high) JMP LOOP PB_PRESSED: CLR P3_7 ; Turn LED on (set P3.7 low) JMP LOOP END
works just fine. When the pushbutton is pressed, the LED lights. Let go and the LED goes out.
But the same program coded in C:
/* C Code - LED Test */ #define Sfr(x,y) sfr x = y #define Sbit(x,y,z) sbit x = y ^ z Sfr (LEDCON, 0x91); /* LED control register */ Sbit (P1_5, 0x90, 5); /* P1.5 - pushbutton switch */ Sbit (P3_7, 0xB0, 7); /* P3.7 - status LED */ void main (void) { LEDCON |= 0xC0; /* Set P3.7 for 10mA LED current limit */ while(1) /* endless loop */ { if (P1_5 == 0) /* Read status of pushbutton switch */ P3_7 = 0; /* Turn LED on (set P3.7 low) */ else P3_7 = 1; /* Turn LED off (set P3.7 high) */ } }
does nothing when loaded into the microcontroller. The code is self-contained (no include files) and the SDCC compiler version is
2.5.0. With both programs, I am using Flip 2.4.4 to download the hex code into the microcontroller, using the USB port. Both assembler and C hex files are downloaded the same way, but assembler code always runs and C code never does, so I believe we can rule out hardware problems and the FLIP software.To compile the C program above, I open a DOS Box (Cmd window) and type: C:\xxx> sdcc testled.c There are no compile errors and SDCC generates all the usual files, including 'testled.ihx'.
I then type: C:\xxx> packihx testled.ihx > testled.hex which generates the 'testled.hex' file and says: packihx: read 26 lines, wrote 14: OK.
When downloaded into the microcontroller flash, the hex file does not run properly. Attempts with other simple test code written in C have failed as well. It is my understanding that SDCC generates 8051 code as a default, but just in case, adding the command line option "-mmcs51" doesn't change anything. The .lst files look okay but contain a lot of other crap which makes them difficult to read.
I know I'm being stupid and missing some step. Can anyone assist the mentally retarded?