2010-10-26 10:42 AM
Struct in Flash
2011-05-17 05:12 AM
''Warning[Pe609]: this kind of pragma may not be used here''
So you need to consult your IAR manuals to see what other kinds of pragmas exist that can be used there... Have you asked IAR about this?
2011-05-17 05:12 AM
__no_init struct {
uint32_t x;
uint32_t y;
} tempor @ 0x0801FFFC;
Is there a way to place data in Flash without giving the address and let the compiler to decide ?
2011-05-17 05:12 AM
He wants it at a specific location.
2011-05-17 05:12 AM
use the ''const'' key word.
usualy all members of the structure must be const struct { const int x; const int y; } const A; should place A into flash2011-05-17 05:12 AM
Hello,
You can use first syntax with #pragma if you declare first the struct and after you reserve it. struct s_tempor { int x ; int y ; } ; #pragma location=0x0801FFFE __no_init struct s_tempor tempor ; Be carrefull in your example, the size of struct is 8 bytes. With a 128 k device, I think the correct address is 0x801FFF8 for the end of Flash. If you don't want to have address in source, you can declare a new section and edit your ICF file to place this section at the correct address in Flash. #pragma location=''.param'' __no_init struct s_tempor tempor ; With this method, you can have several parameters in your project even in different files, and the linker group together all parameters in the same sector of the Flash. Best regards Eric2011-05-17 05:12 AM
2011-05-17 05:12 AM
Or heaven forbid, something crude and relatively portable like
unsigned long *CodeChecksum = (unsigned long *)0x08000640; printf(''%08lX\n'',*CodeChecksum);2011-05-17 05:12 AM
Absoulte placement is possible for variable but not for structure.
CONSTSEG should be defined in linker files based on the size of your structure. Try this one: #pragma location=CONSTSEG const struct{
int x;
int y;
}
tempor; #pragma location=defaultHello, I am trying to write some parameters to the Flash memory
I am using IAR ...
This code works fine :
#pragma location=0x0801FFFE
__no_init char tempor;
but when I try to do something like that :
#pragma location=0x0801FFFE
__no_init struct
{
int x;
int y;
}
tempor;I get :
'' Warning[Pe609]: this kind of pragma may not be used here ..\main.c 35 ''
and the data is placed in RAM
2011-05-17 05:12 AM
A similar way like clive:
typedef struct { uint32_t a; uint32_t b; uint32_t c; } tFlashParams; #define flashParams ((volatile tFlashParams *) 0x0801F000) Be sure, that only 16 bit wide AND 16 bit aligned writes should be used! I would NOT use any way of IAR specific pragma commands!