2022-09-03 09:06 PM
My old project using 16bit infineon MCU with tasking c166, now I am moving to spc5 with free gnu gcc spc5studio.
I am working with typedef struct.
typedef struct
{
struct
{
struct
{
INT16 Rpm[6];
INT16 Load[7];
INT16 Threshold[6];
}
pickup;
} sensor;
UINT16 checksum;
} USERDATA;
in c166 I set a struct object to an absolute address with ___at
USERDATA __at( 0xE00004 ) userData;
how to do the same with spc5 free gnu gcc?
2022-09-03 09:19 PM
Perhaps it would be less disruptive in the Linker Script, as a section?
Or in C just as a pointer with it cast to the appropriate address?
Does it have any initialize content, or is it device unique calibration data written during testing, etc?
2022-09-03 10:16 PM
I need the object in absolute address to manipulate the value by uart, can from PC for calibration. so it will be easier on absolute memory address.
I need the same code that working same as __at in tasking c166 on gnu gcc. any sample code for the section?
2022-09-04 03:51 AM
#define userData (*(USERDATA *)0xE00004)
2022-09-04 06:01 AM
I'd probably move to a model that's not compiler dependent,rather than non-portable
USERDATA *userData = (USERDATA *)0xE00004;
userData[0].checksum =12345;
or
if (userData->checksum == computed) { ... };
or .LD something like
MEMORY
{
...
USRDAT (r) : ORIGIN = 0xE00004, LENGTH= 256
}
SECTIONS
{
...
.usrdat (NOLOAD) :
{
*(.usrdat)
} >USRDAT
...
}
In C, something like
USERDATA userData __attribute__ ((section (".usrdat")));
2022-09-04 08:49 AM
I see, thanks. So the first option, without section is enaugh? What the drawback compare with using section and linker?
2022-09-04 08:49 AM
Thank, let me try
2022-09-04 09:31 AM
But when I try to change the object value, got segmentation fault.
2022-09-04 09:50 AM
Using pointers is most portable.
2022-09-04 10:23 AM
The command to change to checksum value is not working.
userData[0].checksum =12345;