i am facing a problem in Keil uVision3 while running a gsm code. the output window shows fatal error, that i can't debug in the program
unsigned char Rxmsg() { unsigned char i = 0, ret = 0; unsigned int j = 0; unsigned char p[90]; for(i = 0; i < 90; i++) p[i] = 0x00; i = 0; SBUF = 'a'; while(TI == 0); TI = 0; SBUF = 't'; while(TI == 0); TI = 0; SBUF = '+'; while(TI == 0); TI = 0; SBUF = 'c'; while(TI == 0); TI = 0; SBUF = 'm'; while(TI == 0); TI = 0; SBUF = 'g'; while(TI == 0); TI = 0; SBUF = 'r'; while(TI == 0); TI = 0; SBUF = '='; while(TI == 0); TI = 0; SBUF = '1'; while(TI == 0); TI = 0; SBUF = 0x0D; while(TI == 0); TI = 0; for(i = 0; i < 90; i++) { j = 0; while(RI == 0) { if(j >= 1000) delay(1); j++; } p[i] = SBUF; RI = 0; show(p[i]); cmnd(0x18); } return ret; }
output shows: Build target 'Target 1' assembling STARTUP.A51... compiling gsm.c... C51 COMPILER V8.02 COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 2006 *** WARNING C500 IN LINE 1 OF ..\GSM.C: INCORRECT LICENSE ID CODE (LIC) IN 'TOOLS.INI' C51 FATAL-ERROR - ACTION: GOBAL OPTIMIZATION FUNCTION: Rxmsg ERROR: CANNOT OPTIMIZE FUNCTION COMPILATION TERMINATED. use the following work-around: #pragma OPTIMIZE (7) /* your original function */ Rxmsg () { .... } /* end of your original function */ #pragma OPTIMIZE (8) Target not created.
Just a footnote:
unsigned char p[90];
This is a quite large buffer for a 8051, unless it is placed as xdata. Best of all? You are never making use of the full array. You assign the nth position and then you directly print the nth position. Then you never return to that position again.