We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello ,
If I add this function to my C program:
int key_board() { int a = 0,b = 0,c = 0,d = 0,e = 0,f = 0,g = 0,h = 0; int port = 0,r2 = 0,r3 = 0,r4 = 0,r5 = 0,r6 = 0; LED_R = 0; port = KEY_PORT; a = port & 0x03; if(a == 0) // SJMP no Key { return key = 0; } // Waite: while (b != 0) // { entprell(); port = KEY_PORT; b = port & 0x03; } //START_ZYKLUS: r4 = 0xFE; r1 = 0x00; r2 = PORT_ANZ; //Ribbon_1: while (r2 != 0) { r5 = 0x01; r3 = PORT_ANZ; c = KEY_PORT; c = c | KEY_INIT; // bitwise OR c = c & r4; KEY_PORT = c; //Ribbon_2: while (r3 != 0) { // d = r2; d = d ^ r3; // ^ exclusive OR if(d == 0) { // DIAGO f = r5; f <<= 1; // Shift bit to the left r5 = f; r3 = r3 -1; } e = KEY_PORT; e = e & r5; if (e == 0) { // --> TAZU entprell(); h = KEY_PORT; h = h & r5; if ( h != 0) { return key = 0; } if ( h == 0) { return key = 1; } } r1 = r1 +1; f = r5; f <<= 1; // Shift bit to the left r5 = f; r3 = r3 -1; } // End while(r3 !=0) g = r4; g <<= 1; // Shift bit to the left r4 = g; r2 = r2 -1; } // End while(r2 !=0) return key = 0; }
I get the error message:
*** ERROR L107: ADDRESS SPACE OVERFLOW
SPACE: DATA SEGMENT: _DATA_GROUP_ LENGTH: 001AH Program Size: data=132.0 xdata=0 code=1133
Microcontroller AT89C51RC2 with Flash 32 KB
My compiler: Keil-C with C51.exe
How should I specify the data range in my program ?
Kind Regards
Juergen B.
Hello Hans,
many thanks for your response.
The next morning I also thought about using too many variables.
I actually just did that for clarity.
Based on the variables a - h, I only need the variable a = ACC (Akku), and unsigned char r2- r6.
After using only this variable I can compile my program.
“Program Size: data=115.0 xdata=0 code=932”.
But my program is not finished yet.
The background is: I want to convert assembly code into a C program.
The variables r2-r6 should be used as registers R2-R6, analogous to my assembler program.
Another question: can I also use the registers in my C program?
I will take a look at the reference to the use of the other data types.
Juergen