Hi to all
Does anyone know how ,in C language,to impose that a costant be assigned to
a prefixed flash location overriding the linker?
i mean someting analog to the ORG directive in assembler
thank you and Happy new year
Diego
Has been too long since I used HC1X micros.
But in C you can normally use a pointer:
void poke(char *address, char data)
{
unsigned char *my_pointer;
my_pointer = address;
*my_pointer = data;
return;
}
You have to make sure you got bit width right, if your compiler supports it,
(gcc), for example:
uint16_t *my_pointer; // if 16 bit address
unit8_t data; // if 8 bits data
Or something like that.[/QUOTE]
Or just
void poke(unsigned char * address, unsigned char data)
{
*address = data;
}
or
*((unsigned char*)0xf000) = 123;
(Although I am not sure that is quite what the OP was asking for).[/QUOTE]
Thanks but the problem is that i'm compiling for a microprocessor of hc12
family,the 9s12e64,and is not so easy to change te value of the location in
the flash at run time,
as you know you have to erase and re-write a whole flash block,and during
this time the program has to be copied somewhere in RAM,because the MCU
can't read instructions from the flash
during flash manipulation.
Talking about a constant it is easier to declare it in the flash at compile
time,but the linker decides where to put it.
I would be able to set the constant in an absolute location,i.e. 0x4500
Thank you again