This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

"known constants" in memory address space ?



Are there any locations guaranteed or documented to contain particular constants that live in the MSP430 memory address space?

I'm after a "known zero", a "known all ones", and someplace I can write random values and have them just disappear...

I can see such locations with a debugger, but something that would work across all possible CPUs would be nicer.

 

  • You can try the R2 and R3 register. Depending on how (which addressing mode) you access them, the result will be 0, 2,4,8 or -1.
    They are called 'constant generator' and the compiler/assembler automatically uses them when you require an immediate value of one of these 5.
    Also, writing to the R3 register will let the written value disappear. See the users guide for details.

    yet these are registers, not memory locations. There is no known memory location that will always give a certain value. The reason is that nobody will waste silicon in implementing them. Everyhting that is there has a meaning, and what's not there cannot be accessed (will cause a vacant memory violation if you try).

    To have an written value disappear, you can write it to flash. Since writes to flash are ignored when you do not enable the flash controller for write previously, it is a safe thing (albeit I don't know why one should waste code for doing it). Writing to, e.g. 0xfffe (the reset vevtor) or any other flash address or even info memory address will do the job of being a no-op.

**Attention** This is a public forum