I'm attempting to use SDCC (Version #4 May 31, 2007) to compile a C program previously compiled using Keil demo compiler and run successfully on the target (AT89C51ED2). I downloaded the AT89C51xD2 header file for the SDCC compiler from the Atmel web site. Whe I compile the program, I receive three error messages (one each for lines 110, 116, and 118), which is "error 146: two or more storage classes in declaration for 'type_specifier declaration_specifiers' Lines 110, 116 and 118 are included below:
107 // ---------- Data & I/O Variables ----------
109 unsigned char data g_uc_SPI_data=0;
110 bit data g_b_SPI_extracted=0;
112 unsigned char data g_uc_AC_volt_reading=0; // AC voltage sensor reading value 8-bit
114 unsigned char data g_uc_detector_AB_id=0; // detector A & B id values 4-bit each
116 bit data g_b_GFI_bit=0; // ground fault interrupt bit, input (1=GFI circuit trip)
118 bit data g_b_OverTemp_bit=1; // over temperature bit, output (1=no power)
120 unsigned char data g_uc_config_bits=0x00; // general configuration bits (6 upper bits)
I also get three warnings (lines 299, 300 and 461), which is warning 180: using ~ on bit/bool/unsigned char variables can give unexpected results due to promotion to int. The lines are included below:
297 void refresh_stat_LEDs()
301 LED3_PORT_BIT=~0; // unused status LED
I'm a newbie at this. So, although I've searched for more information on the web regarding these errors, I'm still not sure of how to fix these errors/warnings.
By the way, I'm compiling simply using the command line text: sdcc TestMIC.c (which is the name of my file).
Any help or suggestions would be appreciated!
//This confuses SDCC. Is the variable a bit or an integer in data?
bit data g_b_SPI_extracted=0;
For the warnings, instead of
Which should generate this assembly code:
The variable is a bit.
Thanks. The suggestions you made seemed to have worked. I can now compile without errors or warnings. I was able to use packihx to create the hex file from the ihx file and download to the AT89C51. At least part of my program is now working (blinking of LED). The serial communication, however, does not work. I'm using an ISR for this. I don't have a prototype statement for the interrupt function in my code (which consists only of a header file (.h) and the program file (.c)). The SDCC manual is a bit confusing as to whether the prototype statement is needed for a program in which the interrupt function and main() are in the same file. Any other suggestions?
When the interrupt function and main() are in the same file, a prototype of the ISR should not be necessary.