Hello, We are using PK51 for our project using code banking technique. For this we have created 3 source files, 1. One is for common area which contains time ISR, Serial Part ISR and function which are common for anther 2 banks. 2. 2nd source file will load in bank "0" 3. 3rd source file will load in bank "1" Now we having variable for these 3 files. We declared these variables in common source file and declared them variables as external for remaining 2 files. We are having constant variables which are same for these 3 files. But when we compile; PK51 gives us error and it is required that we have to defined these constants variables with separate names in 3 same files. Is there any method like "external variables" so that we can define this constant single time? Example: Part1.c >>> part1.h Part2.c>>> part2.h Part3.c >>> part3.h Constants Part1.h Unsigned char code xyz = {0x01,0X02,0x03}; Part2.h Unsigned char code pqr = {0x01,0X02,0x03}; Part2.h Unsigned char code lmn = {0x01,0X02,0x03};
"Unsigned char code xyz = {0x01,0X02,0x03};" What is this rubbish? Post the actual code you are having trouble with and the exact error message(s) you are getting. Copy and paste from your editor, do not retype.
"Part1.h Unsigned char code xyz = {0x01,0X02,0x03}; Part2.h Unsigned char code pqr = {0x01,0X02,0x03}; Part2.h Unsigned char code lmn = {0x01,0X02,0x03}; " These look like attempts at definitions (with initialisations) - even after fixing the fundamental syntax errors, they should certainly not be in header files! Header files should contain only declarations Every symbol must have exactly one definition - you can have as many declarations for it as you like. Standard 'C' textbook stuff, or try a search of the forum for posts containing both "declaration" and "definition" - there's loads of 'em!
please find attach code: our computer in not connected to internet. for you reference i set bold text for your reference. Thanks in advance. ======================= 1st file start code20.h============================== #ifndef __CODE20__ #define __CODE20__ unsigned char code date_lookup[]={31,28,31,30,31,30,31,31,30,31,30,31}; unsigned char code ring_cad[][151]={ { 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, #endif ===========================================1st file code20.h end=============== ========================2nd file lcode20.h start========================== #ifndef __LEXTCODE20__ #define __LEXTCODE20__ unsigned char code ldate_lookup[]={31,28,31,30,31,30,31,31,30,31,30,31}; unsigned char code lring_cad[][151]={ { 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, #endif ===========================================2nd file lcode20.h end=============== ========================3rd file pcode20.h start========================== #ifndef __PEXTCODE20__ #define __PEXTCODE20__ unsigned char code pdate_lookup[]={31,28,31,30,31,30,31,31,30,31,30,31}; unsigned char code pring_cad[][151]={ { 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, #endif ========================3rd file pcode20.h end==========================
"please find attach code" so you really are defining variables in header files - this will naturally cause you problems! See my earlier post.