16.04.2014 Views

STM8S and STM8A microcontroller families

STM8S and STM8A microcontroller families

STM8S and STM8A microcontroller families

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.

Flash program memory <strong>and</strong> data EEPROM<br />

RM0016<br />

Refer to the option byte section in the datasheet for more information on option bytes, <strong>and</strong> to<br />

the STM8 SWIM protocol <strong>and</strong> debug module user manual (UM0470) for details on how to<br />

program them.<br />

4.5 Memory protection<br />

4.5.1 Readout protection<br />

Readout protection is selected by programming the ROP option byte to 0xAA. When readout<br />

protection is enabled, reading or modifying the Flash program memory <strong>and</strong> DATA area in<br />

ICP mode (using the SWIM interface) is forbidden, whatever the write protection settings.<br />

Furthermore, on medium <strong>and</strong> high density <strong>STM8S</strong> <strong>and</strong> <strong>STM8A</strong>, the debug module (DM)<br />

cannot start code execution by the CPU when the readout protection is active, <strong>and</strong> the CPU<br />

is stalled.<br />

Even if no protection can be considered as totally unbreakable, the readout feature provides<br />

a very high level of protection for a general purpose <strong>microcontroller</strong>.<br />

Removing the readout protection<br />

The readout protection can be disabled on the program memory, UBC, <strong>and</strong> DATA areas, by<br />

reprogramming the ROP option byte in ICP mode. In this case, the Flash program memory,<br />

the DATA area <strong>and</strong> the option bytes are automatically erased <strong>and</strong> the device can be<br />

reprogrammed.<br />

Refer to Table 6: Memory access versus programming method for details on memory<br />

access when readout protection is enabled or disabled.<br />

4.5.2 Memory access security system (MASS)<br />

After reset, the main program <strong>and</strong> DATA areas are protected against unintentional write<br />

operations. They must be unlocked before attempting to modify their content. This unlock<br />

mechanism is managed by the memory access security system (MASS).<br />

The UBC area specified in the UBC option byte is always write protected (see Section 4.4.3:<br />

User boot area (UBC)).<br />

Once the memory has been modified, it is recommended to enable the write protection<br />

again to protect the memory content against corruption.<br />

Enabling write access to the main program memory<br />

After a device reset, it is possible to disable the main program memory write protection by<br />

writing consecutively two values called MASS keys to the FLASH_PUKR register (see<br />

Section 4.8.6: Flash program memory unprotecting key register (FLASH_PUKR)). These<br />

programmed keys are then compared to two hardware key values:<br />

● First hardware key: 0b0101 0110 (0x56)<br />

● Second hardware key: 0b1010 1110 (0xAE)<br />

44/449 Doc ID 14587 Rev 8<br />

www.BDTIC.com/ST

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

Saved successfully!

Ooh no, something went wrong!