hello my friendes.
please help me. l have an error in my project : main.c(25746): error C8 code size exceeds 64K Keil development tools for the XC16x, C16x, and ST10 Microcontroller PK166 Professional Developer's Kit please say tanks very much ,
Wealth of detail to work with here.
Perhaps make your code smaller so it fits in the device and memory model you have chosen.
So don't do that, then!
How much code space does your target actually have?
help Excuse me, I can't speak english very well . I use a Microcontroller ST10F276 and keil compiler in my project . My project is needed about 500 Kbyte IFASH for code and 6 or 8 Kbyte IRAM or XRAM for variable. Microcontroller ST10F276 have a 2 Kbyte 16 bit wide IRAM, a 66 Kbyte 16 bit wide on chip XRAM, a 512 Kbyte 16 bit wide on chip internal Flash (IFLASH) and a 320 Kbyte 16 bit wide on chip extended Flash (XFLASH). but when I compile my project, keil compiler prepare this error :main.c(25746): error C8: code size exceeds 64K .
Please see my project setting : Options for Target 'Taret 1' tab - Target
STMicroelectronics ST10F276 Select : Use On chip ROM(832) Select : Use On chip CAN+XRAM(0xE000 - 0xE7FF) Select : Use On chip XRAM(0xF0000 - 0xFFFFF) Clock (MHz) : 64.0 Memory Model : Medium 'near' data 'far' funcs Operating System : None Data Threshold : near 6 Near Memory : 16 KB RAM, 16 KB ROM
External Memory : Start Size #1 ROM 0x00 0x8000 #2 RAM
Please help me to eliminate this error : main.c(25746): error C8: code size exceeds 64K in my project.
If you take a look at the forum activity, you'll see that very, very few people are using this particular toolchain - so you probably need to be looking to specialists for support.
It seems that you have a licence - so have you contacted Keil support? Or the distributor where you purchased the product?
http://www.keil.com/support/man/docs/c166/c166_c8.htm http://www.keil.com/support/man/docs/c166/c166_er_reference.htm
Do you have a main() function that is very large?
How many lines is main.c? >26K lines I'd guess
The manual says to split into smaller modules, so partition your design, start with smaller files, with less lines. Some places I've dealt with have a single function per file policy, while this is a bit extreme, it might work here. At the very least try to break things into functional units/groups so you don't have one file with tens of thousands of lines.
Ultimately learn to use Google. I'm not using the C166, but found this in seconds.
hello my friend yes, my project is very large and complex, it needs about 500 Kbyte flash memory for code and about 8 Kbyte ram memory for variable definition, this project is a Industry project and Practical and I need to use ST10F276 microcontroller since this micro provide my needs and it has on chip peripheral blocks and Important of all that it is in market of my country.
With respect Thanks a lot,
hi Yes, You are right, My project is very large and I know it, I tried to break it to smaller segment and more functions in result this code with this volume Created, My project is very larger than this code, Even original project is larger than it and It has about 50 k lines, also I have study the compiler Help and I know how I use it, but I want to solve it in same form Because My project has many functions and variables that I can't ignore them or I delete them,
But The problem is here, I do not know how to segment the program and divide it into smaller modules Because Project has many global variables and constant that It is used throughout the program.
in the end Thanks you
So move all the globals into a file, global.c, and then make a global.h file that describes them as "extern"s and #include that file into all you sub files.
Study how to partition a project into multiple files, have huge files with 50K lines is atypical, look at how other people build and manage large projects.
hi First, Thank you for your advice. I split the program into several sections, Multiple header files for global constants that are used in several files and several header files for setting up the microcontroller's side units, including analog-to-digital converter, spi unit, uart unit, can unit and so on, including the source file, Global variables move into a global.c, and then make a global.h file, But when using "extern"s, the compiler declares an error, Problem is there , If you can provide a small example that includes the header and source file, and it's a syntax to describe it, you've helped me a lot because some compilers do not follow standard programming. And this is my problem.
Thank you for spending my valuable time on my guide. Best regards, thank you very much
So what error does the compiler declare ?
How do you expect anyone to advise you on how to fix this error without knowing what the error is?!
Copy & paste the full error text from uVision into the forum - do not manually type it.
"this project is a Industry project"
So do you not have colleagues and/or supervisors who can help you with this?
It is a lot easier for someone to help you when they can see what you're actually doing, and see what's actually happening, and know what you're actually doing.
"I can't speak english very well"
Another huge advantage of seeking help locally!
In global.h
extern int glovar;
In global.c
int glovar = 123;
This type of construct should work on any remotely functional C compiler from the last 3 decades.
If you have an error you're going to need to be a lot more explicit about the details reported by the compiler and/or linker.
Review some large project on GitHub to see how people successfully partition code.
Having lots of random global variables is something people in general have tried to limit in the past. Consider using structures to collect things together, and review if the use of scoped auto/local variables can reduce the need to commit resources across the life of the application.
You'd have thought that someone working on such a large, "Industry" project would understand this - or, at least, have co-workers who could provide guidance & support ...
I made a small mistake that I defined the variables in the original file and immediately gave them the initial value, then I copied these variables the same way in another file, I used the "external" for the variables in the attached file. But I forgot that these variables should not be initialized in two separate files. The reason for this was my rush in programming. In this case, the compiler provides a link error and states that this variable (symbol) is defined in several files and is not capable of linking.
in main file
#include <> #include "" // global variable unsigned int gtmp1 = 0,gtmp2 = 0,gtmp3 = 0; unsigned short adc_data[16] = {0}; void main(){ unsigned int tmp1,tmp2,tmp3; while(true){ ...... ...... } // end of while loop function } // end of main function
in adc header file
#ifndef __ADC #define __ADC // Prototypes - Note: ISRs prototyped above. void adc_init(void); void get_adc(char chan1, char chan2); void adc_pec_init(unsigned short adc_data[], unsigned char num); #endif
in adc source file
#include "adc.h" // extern unsigned short adc_data[16] = {0}; // void adc_init(void) { ADCIC = 0x007F; // 0x0078; P5DIDIS = 0xFFFF; // load Port 5 digital input disable register ADDAT = 0x0000; // load A/D converter result register ADDAT2 = 0x0000; // load A/D converter 2 result register /// - auto scan continuous conversion mode is selected /// - repeatedly converts channel 15 /// - ADC start bit is set /// - 'wait for ADDAT read mode' is disabled /// - converter basic clock tbc is fcpu / 4 /// - sample time tsc is tbc * 8 ADCON = 0x00BF; // load ADC control register IEN = 1; // Global Interrupt enable } // void adc_pec_init(unsigned short adc_data[], unsigned char num){ /// - auto scan continuous conversion mode is selected /// - repeatedly converts channel 15 /// - ADC start bit is set /// - 'wait for ADDAT read mode' is disabled /// - converter basic clock tbc is fcpu / 4 /// - sample time tsc is tbc * 8 /// ----------------------------------------------------------------------- /// Configuration of the used ADC Interrupts: /// ----------------------------------------------------------------------- /// - Conv service request node configuration: /// - Conv interrupt priority level (ILVL) = 14 /// - Conv interrupt group level (GLVL) = 0 /// Use PEC channel 0 for ADC Conv INT: /// - decrement counter /// - increment destination pointer /// - transfer a word // load PECC0 control register PECC7 = 0x0200 | (num & 0xFF); // ( (sizeof(adc_data) / sizeof(adc_data[0])) ); SRCP7 = (unsigned int)&ADDAT; // DSTP7 = _sof_(adc_data); // } // End of function ADC_Init // example : // adc_pec_init(adc_data, sizeof(adc_data)); // void get_adc(void){ }
As you can see, the variable one in both files has an initial value that should be in the second file without an initial value and should be modified as follows.
#include "adc.h" // modified extern unsigned short adc_data[16]; // void adc_init(void) { ADCIC = 0x007F; // 0x0078; P5DIDIS = 0xFFFF; // load Port 5 digital input disable register ADDAT = 0x0000; // load A/D converter result register ADDAT2 = 0x0000; // load A/D converter 2 result register /// - auto scan continuous conversion mode is selected /// - repeatedly converts channel 15 /// - ADC start bit is set /// - 'wait for ADDAT read mode' is disabled /// - converter basic clock tbc is fcpu / 4 /// - sample time tsc is tbc * 8 ADCON = 0x00BF; // load ADC control register IEN = 1; // Global Interrupt enable } // void adc_pec_init(unsigned short adc_data[], unsigned char num){ /// - auto scan continuous conversion mode is selected /// - repeatedly converts channel 15 /// - ADC start bit is set /// - 'wait for ADDAT read mode' is disabled /// - converter basic clock tbc is fcpu / 4 /// - sample time tsc is tbc * 8 /// ----------------------------------------------------------------------- /// Configuration of the used ADC Interrupts: /// ----------------------------------------------------------------------- /// - Conv service request node configuration: /// - Conv interrupt priority level (ILVL) = 14 /// - Conv interrupt group level (GLVL) = 0 /// Use PEC channel 0 for ADC Conv INT: /// - decrement counter /// - increment destination pointer /// - transfer a word // load PECC0 control register PECC7 = 0x0200 | (num & 0xFF); // ( (sizeof(adc_data) / sizeof(adc_data[0])) ); SRCP7 = (unsigned int)&ADDAT; // DSTP7 = _sof_(adc_data); // } // End of function ADC_Init // example : // adc_pec_init(adc_data, sizeof(adc_data)); // This function is very large void get_adc(void){ }
A bit of rush in programming and carelessness causes a small error. Dear friend, Regards, Thank you for your guidance.