This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

external code variable

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};

Parents
  • 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==========================

Reply
  • 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==========================

Children