Docsity

Memory Mapping and Flash Memory Management in HCS12 Microcontroller - Prof. Bradley J. Baz, Study notes of Microcomputers

Partial preview of the text

Download Memory Mapping and Flash Memory Management in HCS12 Microcontroller - Prof. Bradley J. Baz and more Study notes Microcomputers in PDF only on Docsity!

ECE 4510 Introduction to

MicroprocessorsMicroprocessors

Ch

t

Chapter 14

Dr. Bradley J. BazuinAssociate Professor

Department of Electrical and Computer Engineering

College of Engineering and Applied Sciences

Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

College of Engineering and Applied Sciences

Chapter 14

p

•^

Memory Systems

y^

y

–^

Internal Memories•

FLASH – Program Memory – 512 kB• RAM – Data Memory – 14 kBRAM

Data Memory

14 kB

•^

EEPROM – 4 kB

–^

External Memory ExpansionM

Ti

i^

A

l^

i

–^

Memory Timing Analysis

Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

ECE 4510

Module Mapping and Control

pp

g

•^

Module Mapping Control (MMC)

pp

g^

(^

Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

ECE 4510

MMC Features

•^

Registers for mapping of address space for on-chip RAM, EEPROM, andFLASH (or ROM) memory blocks and associated registers

•^

Memory mapping control and selection based upon address decode and systemoperating modeC^

dd

b^

l

•^

Core address bus control

•^

Core data bus control and multiplexing

•^

Core security state decodingE^

l^

i^

hi

l^

i^

l^

i^

(ECS)

•^

Emulation chip select signal generation (ECS)

•^

External chip select signal generation (XCS)

•^

Internal memory expansion

l^

h^

d^

O^

i^

l f

i^

i^

h^

SC

i

•^

External stretch and ROM mapping control functions via the MISC register

•^

Reserved registers for test purposes

•^

Configurable system memory options defined at integration of Core into theS^

t^

Chi

(SOC)

Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

System-on-a-Chip (SOC).

ECE 4510

Internal Resource Remapping (2 of 2)

Table 14.1 Mapping precedence

pp

g (

Precedence

Resouce

1 2

BDM firmware or register space

Internal register space

3 4 5 6

SRAM blockEEPROMflash memory

Remaining external memory

g^

y

Example in the dp512:

•^

The EEPROM and register space overlap.The register space takes precedence.

Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

Register Block Mapping

g

pp

g

•^

The register block may be 1 KB or 2 KB in size.

g^

y

–^

Register block remapping is controlled by the INITRG register.

–^

The register block can be remapped to any 2 KB boundary withinthe first 32 KB of memory (A15=0)

7

6

5

3

2

1

the first 32 KB of memory (A15 0).

–^

Default Offset 0x

7

6

5

4

3

2

1

0

value after

reset:

0

0

0

0

0

0

0

0

0

REG14 REG

REG12 REG

0

0

0

REG14~REG11: Internal register map position

base + $

REG

REG11: Internal register map position These four bits along with bit 7 specify the upper 5 bits of the 16-bitregister address. These four bits can be written only once in normalmodes and can be written many times in special modes. There is norestriction on the reading of this register.^ Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

Figure 14.1 Contents of the INITRG register

EEPROM Mapping

pp

g

•^

The EEPROM can be remapped to any 2 KB boundarywithin the 64 KB memory space.–

The remapping of the EEPROM is controlled by the INITEEregister.– The EEPROM is enabled by the bit 0 of the INITEE register.– Default: dp512 is 0x

value after

reset:

EE

EE

EE

EE

EE

EEON

EE15~EE11:InternalEEPROM

map

position

These bits specify the upper 5 bits of the 16 bit registers address

base+$

These bits specify the upper 5 bits of the 16-bit registers address.These five bits can be written only once in normal modes and can bewritten many times in special modes. There is no restriction on thereading of this register.EEON:Internal

EEPROM On (Enabled

reading).

0 = Removes EEPROM from the map.1 = Places the on-chip EEPROM in the memory map

Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

1 = Places the on-chip EEPROM in the memory map.

Figure 14.3 Contents of the INITEE register

Miscellaneous System Control

R

i t 7

Register

•^

This register

reset value:

1 _
EXSTR
ROMON
EXSTR
ROMHM

base+$

expanded oremulationperipheral orsingle chipspecial test

g

enables/disables theon-chip ROM andallows one to stretch

EXSTR1~EXSTR0: External access stretch bits 1 and 000 = no stretch to external bus cycle01 = stretch the external bus cycle by one E cycle10 = stretch the external bus cycle by two E cycles11 = stretch the external bus cycle by three E cycles

special test

allows

one to stretch

the length of theexternal bus cycle.

stretch the external bus cycle by three E cycles

ROMHM: Flash EEPROM or ROM only in second half of memory map0 = The fixed page (s) of flash EEPROM or ROM in the lower half of

the lower half of the memory map can be accessed.

1 = Disable direct access to the flash EEPROM or ROM in the lower

half of the memory map. These physical locations of flash memorycan still be accessed through the program page window

–^

The value of theROMONE pin islatched to the ROMONbi

f h

MISC

can still be accessed through the program page window

ROMON: Enable flash memory or ROM0 = Disable the flash memory or ROM in the memory map1 = Enable the flash memory or ROM in the memory mapNote:1. The reset state of this bit is determined at the chip integration level.

bi

t of the MISC

register after reset.

–^

Default:

Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

Figure 14.4 Contents of the MISC register

Table 14.2 Allocated RAM memory spaceRAM_SW2:RAM_SW

AllocatedRAM space

RAM mappable

region

INITRMbits used

RAM resetbase address

(1)

y^

p

2K bytes4K bytes6K bytes

2K bytes4K bytes8K bytes

(2)

RAM15~RAM11RAM15~RAM12RAM15~RAM

6K bytes8K bytes10K bytes12K bytes14K bytes16K bytes

8K bytes8K bytes16K bytes

(2)

16K bytes

(2)

16K bytes

(2)

16K bytes

RAM

RAM

RAM15~RAM13RAM15~RAM14RAM15~RAM14RAM15~RAM14RAM15~RAM

Notes:1. The RAM reset base address is based on the reset value of the INITRM register, $09.2. Alignment of the allocated RAM space within the RAM mappable region is depedent

on the value of RAMHAL.^ Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

Memory Size Register One

(MEMSIZ1)(MEMSIZ1)

•^

This register is

ROM_SW1ROM_SW
PAG_SW1 PAG_SW
--^
--^
--^
--^
--^
--^
--^

reset:

ROM_SW1~ROM_SW0: Allocated system flash or ROM physical memory space

base+$1D

g

read-only andreflects the state ofthe flash or ROM

00 = 0 KB01 = 16 KB10 = 48 KB11 = 64 KBPAG_SW1~PAG_SW0: Allocated off-chip flash or ROM memory spaceThe allocated off-chip flash or ROM memory space size is as given in Table

the

flash or ROM

physical memoryand paging

The allocated off chip flash or ROM memory space size is as given in Table 14.3. PAG_SW1~PAG_SW

Off-chip space

On-chip space

876 KB

128 KB

Table 14.3 Allocated off-chip memory options

switches at the coreboundary.– Default: 0x

768 KB512 KB0 KB

256 KB512 KB1 MB

Figure 14.6 Memory size register one (MEMSIZ1)

48 kB Flash Space,512 kB Flash

Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

FLASH MAP

Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

ECE 4510

Expanded Memory Mapping

p

y

pp

g

•^

The HCS12 uses the PPAGE register to determine which of the 64 possible16 KB pages is active in the program window16 KB pages is active in the program window.–

The direct concatenation of the page number and the page offset does not result in linear addresses.

•^

Motorola proposed the following method to address memory above 64 KB:1.

Use $00 to $3F as the page numbers for the 64 16-KB pages.

p g

p g

2.^

Use higher page numbers to select on-chip flash memory (The rest of the 512 kB available).For example, the HCS12 devices with 512KB flash memory assign $20 to $3F as the pagenumbers of the 32 on-chip 16 KB pages. Use $00 to $1F as page numbers for external memory 3

Use linear addresses to address external memory and also use linear method to address machine

P^

N^

SR

Add

/ PPAGEWi Si

3.^

Use linear addresses to address external memory and also use linear method to address machinecodes for S records.

4.^

Compute the page number and page address within the $8000~$BFFF page window using thefollowing equations:

PageNum = SRecAddr / PPAGEWinSize

PageWinAddr = (SRecAddr % PPAGEWinSize) + PPAGEWinSTART

where,

SRecAddr is the linear address used in S records

Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

PageWinAddr is a number between $8000 and $BFFF.PPAGEWinSize = 16K = $

Example 14.2 & 14.

What are the PageNum and PageWinAddr for the SRecAddr of $E1003?

p

What are the PageNum and PageWinAddr for the SRecAddr of $E1003?• Solution: Apply equation 14.1 and 14.2 as follows:PageNum

= $E1003 / $4000 = $

PageNum

$E1003 / $

PageWinAddr

= ($E1003 % $4000) + $8000 = $1003 + $8000 = $

What is the corresponding SRecAddr for the pair of (PageNum PageWinAddr)What is the corresponding SRecAddr for the pair of (PageNum, PageWinAddr)equal to ($20, $A003)?• Solution: Apply equation 14.3 as follows:

pp y

q

SRecAddr

×

$4000 + $A003 - $8000 = $

Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

On-Chip Flash Memory (1 of 3)

p

y (

•^

The on-chip flash memory size can be 32 KB, 64 KB, 128

p^

y^

,^

KB, 256KB, and 512 KB for the HCS12 devices.

•^

A flash memory larger than 64 KB is divided into 64-KBbl

k^

(128 KB bl

k^

f^

d 512)

blocks (128-KB blocks for dp512).

•^

Programming and erasure of flash memory are performedby sending commands to the command register.by se d

g co

a ds to t e co

a d eg ste.

•^

The flash memory has a flexible protection scheme againstaccidental programming and erasure.

•^

The flash memory also implements security measures toprevent the application code from being pirated.

•^

The flash memory map is shown in Figure 14 8

Material from or based on:

The HCS12/9S12: An Introduction to Software & Hardware Interfacing

, Thomson Delmar Learning, 2006.

•^

The flash memory map is shown in Figure 14.8.