EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Placing Code In Information Memory

Started by iob prosia ii November 20, 2007
Hi everyone,

My name is Ray and i have a problem in converting a code to IAR EW430. the present code i have is compiled in Quadravox and i need this to be compiled in IAR. Below is the code which i have difficulty to convert it the same way in IAR.

/** The info flash starts at address 0x1000 and is 128 bytes */
_INFOMEM const union
{
uint8_t InfoFlash;
uint8_t info_mem[128];
} info_seg;

i suspect that _INFOMEM is internally defined by Quadravox and this function should be done in information memory. Please verify if i understand it right.
Here is my version of the code in IAR.

#pragma location = "INFO"
const union
{
uint8_t InfoFlash;
uint8_t info_mem[128];
} info_seg;

Please advise if this is correct. I intend the info flash to start at address 0x1000h. I'm not sure if this code follows my intention. Please advise also some effective suggestions.

All replies are very much appreciated.

Thanks,

Ray

---------------------------------
Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how.

Beginning Microcontrollers with the MSP430

> #pragma location = "INFO"
> const union
> {
> uint8_t InfoFlash;
> uint8_t info_mem[128];
> } info_seg;

Hi,
This code is correct if segment is called "INFO", exact name You can
get from .xcl (Linker configuration) file of Your project. You can
also add __no_init before const, this will exclude initialization of
your constant by compiler.
Also, You may want to place constant at exact address. To do so, try
__no_init const @ 0x1000;

Exact information about info-memory You can get from datashhet on
Your device.

Max.
Constants defined with 'const' are not initialized,
therefore '__no_init' is only useful by variables.
Maybe '__root' is helpful, to force the compiler to place the
constant in memory and not to optimize it away.
There was a problem with optimization some time ago in another
thread, where __root helped to solve it.

--- In m..., "g0tty0" wrote:
>
> > #pragma location = "INFO"
> > const union
> > {
> > uint8_t InfoFlash;
> > uint8_t info_mem[128];
> > } info_seg;
>
> Hi,
> This code is correct if segment is called "INFO", exact name You
can
> get from .xcl (Linker configuration) file of Your project. You can
> also add __no_init before const, this will exclude initialization
of
> your constant by compiler.
> Also, You may want to place constant at exact address. To do so,
try
> __no_init const @ 0x1000;
>
> Exact information about info-memory You can get from datashhet on
> Your device.
>
> Max.
>
--- In m..., "bb_stefan" wrote:
>
> Constants defined with 'const' are not initialized,
> therefore '__no_init' is only useful by variables.

Hi, You are right. But using such declaration:
const char Shift_T @ 0x1000
leads to the followings line in firmware:
@1000
00 00
In some cases it is not acceptable.

Max.
> const char Shift_T @ 0x1000
> leads to the followings line in firmware:
> @1000
> 00 00
> In some cases it is not acceptable.

I don't know in which case this not acceptable?
Defining a constant implies assigning a value to it
(otherwise it was not a constant). So if you do not
define a value for the constant then the compiler will
probably do a standard zero-ing.

If you want a placeholder in INFO-Memory, which you can access
from outside the C, then defining a variable is the right choice.
But then with __no_init :-)



> I don't know in which case this not acceptable?
> Defining a constant implies assigning a value to it
> (otherwise it was not a constant). So if you do not
> define a value for the constant then the compiler will
> probably do a standard zero-ing.

Hi,
In case when You need to upgrade Your firmware but keep configuration
or other information unchanged. In case when You don't need rarely
updateable constants, it better to place them in CODE segment.

Max.

The 2024 Embedded Online Conference