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 ,
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.