User manual

UM0036 STM8 C tutorial
Doc ID 7705 Rev 11 355/385
12.6 Perform memory mapping
Memory mapping is the process of defining which areas of memory can be accessed by the
application and the type of access permitted, (for example, read only or read/write). This
allows verification of the application’s use of memory, ensuring that only memory locations
which will exist in the target controller are addressed.
In this lesson you will learn how modify the default memory mapping. Specifically, we are
going to create a new range of ROM within an existing RAM memory range.
To do this:
1. Select Debug Instrument>MCU Configuration.
2. Select the range of RAM that contains the address 0x00.
3. Click on the Modify Area button.
4. In the New MCU Memory Range dialog box type the address 0x00 in both the From
and To fields, and change the memory type to ROM for the single address range.
5. Click on OK in the New MCU Memory Range dialog box.
6. Click on OK in the MCU Configuration window.
7. From the main menu select Debug>Run.
8. A memory access error is displayed, because the address 0x00 corresponds to the
address of the currentState variable in our tutorial program. When we ran our
program, the error occurred when the program tried to write the new value of
currentState to its address 0x0000, which we mapped as a read only section of
memory.