Hi all, i need a help to move my first pass into this world of programming. I use a Cortex-M0 and my question is: how can I access to register R0-R12.. in language C? it's possible? I would save a variable into one register. Thanks bye.
But what does that have to do with register accesses?
The normal way to store variables is to actually use variables...
My intention was to save the specific variable into one register when the reset occurs, because now when reset occurs all variable return to value 0. I don't want to save the variable to flash because i need too flash all page..
My intention was to save the specific variable into one register when the reset occurs ...
Not a very good idea. When the processor resets that register is going to be used by the bootstrap and startup code. Bang goes your precious value.
So why didn't you start by telling what problem you wanted to solve, instead of directly deciding on a solution and then banging your head when you got stuck?
Why not adjust the RAM memory size in the project settings and make the RAM 4 byte smaller - then store your value in these 4 bytes? The RAM only gets zeroed because the startup code is instructed to initialize the RAM - but RAM it hasn't been instructed to zero will not be zeroed. There are also options to specify that a block of RAM should not be zero-initialized.
thank you vary much!. Ok now i try to reserve a portion of RAM.
There are also options to specify that a block of RAM should not be zero-initialized.
Where is this option?
Thanks.
My intention was to save the specific variable into one register when the reset occurs, because now when reset occurs all variable return to value 0.
That's not how it is done. You should use an ordinary static variable. After reset, you read it before the startup code clears it, or you use compiler facilities to suppress initialization of this particular register. The CPU reset itself does not alter the contents of RAM (unless it is SDRAM and refresh process is suspended for too long).
Shrink IRAM1 from say 0x5000 to 0x4FFC in the Target dialog
*((unsigned long *)0x20004FFC) = 0x12345678; // .. RESET unsigned long bootval = *((unsigned long *)0x20004FFC);