12.07.2015 Views

The Circuit Designer's Companion - diagramas.diagram...

The Circuit Designer's Companion - diagramas.diagram...

The Circuit Designer's Companion - diagramas.diagram...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

224 <strong>The</strong> <strong>Circuit</strong> Designer’s <strong>Companion</strong>ProgramROMUsedUnusedProgram & dataNOPNOPNOPNOPEmpty memoryNOPJMP RESETFigure 6.36 Protecting unused program memory with NOPs(safely) until it reaches the JMP RESET, at which point it restarts.<strong>The</strong> effectiveness of this technique depends on how much of the total possiblememory space is filled with NOPs, since the processor can be corrupted to a randomaddress. If the processor accesses an empty bus, its action will depend on the meaningof the #FF H instruction. <strong>The</strong> relative cheapness of large ROMs and EPROMs meansthat you could consider using these, and filling the entire memory map with ROM, evenif your program requirements are small.6.5.3 Re-initialisationAs well as RAM data, you must remember to guard against corruption of the set-upconditions of programmable devices such as I/O ports or UARTs. Many programmersseem to assume that once an internal device control register has been set up (usually inthe initialisation routine) it will stay that way forever. This is a dangerous assumption.Experience shows that control registers can change their contents, even though they arenot directly connected to an external bus, as a result of interference. This may haveconsequences that are not obvious to the processor: for instance if an output port is reprogrammedas an input, the processor will happily continue writing data to it obliviousof its ineffectiveness.<strong>The</strong> safest course is to periodically re-initialise all critical registers, perhaps in themain idling routine if one exists. Timers, of course, cannot be protected in this way. <strong>The</strong>period between successive re-initialisations depends on how long the software cantolerate a corrupt register, versus the software overhead associated with the reinitialisation.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!