Bryce Zhu

fixed address about MPC5604 platform

Discussion created by Bryce Zhu on Dec 12, 2017

Hi, expert:

I have two questions about using MPC5604 platform.


Question 1(about volatile):

I  used keyword "volatile" to define a const. The code is shown below:

#pragma push
#pragma section code_type ".user_data"
volatile const uint8 COMBINE_FLAG = 0x1;

#pragma pop

If I only define this const and don't use it. The const will be optimized. The size of the section ".user_data" is 0.


If I use the const, For example:


uint8 read_flag;
read_flag = COMBINE_FLAG;

The const will have address. The size of the section "user_data" is greater than 0.


The Global optimizations is:

Why the keyword "volatile" and "const" have no effect?


Question 2(about fixed address):

In 9S12 platform, I can figure the fixed address in coding:

const uint8 COMBINE_FLAG @0xEF00;

But the "@" can't be used in MPC5604 platform. When I compile the code with codewarrior, the compiler tell me:

Besides using "pragma" keyword,  How can I allocate a const in a fixed address?