??? 04/28/10 04:45 Read: times |
#175477 - Definitely desperate measures Responding to: ???'s previous message |
Andy Neil said:
Per Westermark said:
If the processor has a register that you don't need to use, then you can use it as a variable. But remember that SFRs are not just memory - they directly affect hardware. And not all registers will read-back the same value that you just wrote... But I don't think that was the question: Kaustav Dey Biswas said:
... fit in some program variables in the un-utilized spaces of the SFR memory region (0x80 - 0xFF)? I think he's talking about locations in SFR space that are not documented as being used at all. It would be an extremely bad idea to mess with them!! Of course, you should look for a different processor unless you are critically desperate. Absolutely As soon as you start with ugly workarounds it can only go downhills. Indeed. Yes. If a port register is used as memory cell, there can be a lot of actions on external memory pins. Using a baudrate register can also result in strange things. That of course means that any abuse of a register as a memory location (single-bit or byte) requires careful analysis of the definitions of the registers - is it 100% R/W, and what happens if a random value gets written to the register. A lot of the registers (maybe even most of them) have side effects that makes them unsuitable for use as generic variable space. The reason my answer did mention registers and not the space between registers is of course that the void between the registers are an "unknown". There may exist memory there. There may not. Writing to addresses that are not documented in the datasheet is normally a no-no, just as writing (non-zero) to undefined bits in registers is a no-no. Not only is it undocumented if it is possible to find memory between the SFR. Any such space may also be reserved for specific use - maybe factory test? Maybe differences between different steppings? Maybe additional data for a big-brother model of the processor. Unless the original software was written by very skilled developers, a careful code review can normally find variables that may be removed or code that may be rewritten to solve the problem in a traditional way. But if the original software was written by very skilled developers who did manage to optimally use the last bit of data space, then the project should have looked for a different processor way earlier, since it's too dangerous to push too close to the limit without having a working backup plan. |
Topic | Author | Date |
Utilizing the SFR memory space for storing variables | 01/01/70 00:00 | |
Variables at absolute addresses | 01/01/70 00:00 | |
That wasn't the question | 01/01/70 00:00 | |
Definitely desperate measures![]() | 01/01/70 00:00 | |
Not to be relied upon | 01/01/70 00:00 | |
Extending "efficient as possible"... | 01/01/70 00:00 |