Global variable not allocated

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Global variable not allocated

Jump to solution
784 Views
crouse
Contributor I

Hi all :

 

I'm use CW5.9  for MC9S08AC32 before , and I creat a file(.h file) for store for globe variable for main.c & MCUinit.c include use,

 

when debugging (use DEMOAC for programming), the Data window can view globe variable directly and refresh period , very convenient,

 

for ROM size not enough (move to MC9S08AC48) , I use CW6.3 ,

 

but same code in CW6.3 , the global variable show in Data window "not allocated" , could any one can give an advise?

 

the globe variable default as below :

//---------------------------------------------------------

#ifndef VARIABLE_H

#define VARIABLE_H

 

#include "mc9s08ac48.h"

 

#define unsigned8 unsigned char

#define unsigned16 unsigned int

//----- variables ---------------------------------------

extern unsigned8    TestFan_Cnt;    

extern unsigned8    Relay_Off_60_Cnt;

extern unsigned8    Relay_Off_20_Cnt;

extern unsigned16   Sleep_30min;

 

typedef union {

  byte Byte;

  struct {

    byte OD_Err            :1;                                  

    byte OD_Restraint    :1;                  

    byte                         :1;                             

    byte                         :1;                          

    byte                         :1;                        

    byte                         :1;                             

    byte                         :1;                               

    byte                         :1;                         

  } Bits;

} ODEC;

extern volatile ODEC       _OD_Err_Code_;

#define OD_EC_Code     _OD_Err_Code_.Byte

#define OD_Err               _OD_Err_Code_.Bits.OD_Err

#define OD_Restraint      _OD_Err_Code_.Bits.OD_Restraint

#endif

 

//------------------------------------------------------------------------------------------------

 

I also use

 

1. "volatile" for prevent optimise.

 

2. Edit -> Standard settings -> Compiler for HC08 -> Smart Sliders -> Debug Comlexity ->  low.

 

, it's still not working ...

 

訊息由此人編輯:crouse shaw

Labels (1)
0 Kudos
1 Solution
566 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

I also you just submitted a service request and i just answered.

the problem is that you didn't define the variable in C code but only declare it.

For example for the first <not allocated> variable _CPS_STATUS_FLAG_, I searched your project, I can only saw it declare as external in cmn_variable.h:

extern volatile CPS _CPS_STATUS_FLAG_ ;

you didn’t define _CPS_STATUS_FLAG_ it in C code anywhere.

So I add :

volatile CPS _CPS_STATUS_FLAG_ ;

to main.c.

in debugger I can see _CPS_STATUS_FLAG_ show out.

View solution in original post

0 Kudos
5 Replies
566 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

i wonder the problem due to the optimization,

put the variable to .prm ENTRIES section to see if this can solve the problem

syntax:

ENTRIES

variable_name1 variable_name2

END

0 Kudos
566 Views
crouse
Contributor I

Thanks, Jennie

But it also can not work after I use the method  :smileycry: 

the .prm file as below :

prm.JPG.jpg

0 Kudos
567 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

I also you just submitted a service request and i just answered.

the problem is that you didn't define the variable in C code but only declare it.

For example for the first <not allocated> variable _CPS_STATUS_FLAG_, I searched your project, I can only saw it declare as external in cmn_variable.h:

extern volatile CPS _CPS_STATUS_FLAG_ ;

you didn’t define _CPS_STATUS_FLAG_ it in C code anywhere.

So I add :

volatile CPS _CPS_STATUS_FLAG_ ;

to main.c.

in debugger I can see _CPS_STATUS_FLAG_ show out.

0 Kudos
566 Views
crouse
Contributor I

Big Thanks !  :smileyhappy:

This problem took me few days,

I can continue go my project again, YEAH!

0 Kudos
566 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

good to know your problem was solved. you are welcome!

0 Kudos