English
Language : 

PXS20RM Datasheet, PDF (1192/1368 Pages) Freescale Semiconductor, Inc – PXS20 Microcontroller
Register Protection (REG_PROT)
40.5 Initialization/application information
40.5.1 Reset
The reset state of each individual bit is shown within the register description section (See Section 40.3.2,
Register descriptions). In summary, after reset, locking for all MRn registers is disabled. The registers can
be accessed in supervisor mode only.
40.5.2 Writing C code using the register protection scheme
There is a set of macros provided as part of the device specific header file, which defines the memory map,
the peripheral registers, and the fields of these registers. These macros are intended to make working with
the register protection scheme easier for the developers of device driver software and/or other application
code. This section describes these macros and how to use them.
A first macro is made available to perform a write to the mirrored module register space (Area 3). As
described in this document, this results in concurrently setting the corresponding soft lock bit, while
writing to the module register. There are three flavors of this macro, to account for the different size of the
related module register <thereg> (the value of <size> is either 8, 16, or 32 bit):
WRITE_WITH_LOCK<size>(<thereg>, <newvalue>)
This macro writes the value <newvalue> into the register <thereg> assuming a register size of <size>. The
parameter <thereg> must be the name of a register using the notation in the device specific header file.
A second set of macros is made available to work with the soft lock bits provided by the register protection
scheme. The value of these bits associated with a particular module register <thereg> can be retrieved, set,
and cleared. The macros provided for this purpose are:
GET_SOFTLOCK(<thereg>,<dest>)
SET_SOFTLOCK<size>(<thereg>)
CLR_SOFTLOCK<size>(<thereg>)
The macro GET_SOFTLOCK retrieves the value of the soft lock bit register associated with the given
register <thereg> and stores it in the variable <dest>; which is always an eight bit value. The other two
macros (SET_SOFTLOCK, CLR_SOFTLOCK) set or clear the softlock bits associated with the given
register <thereg>; assuming this register has a size of 8, 16, or 32 bit as indicated by the macro name. For
all three macros, the parameter <thereg> must be the name of a register using the notation in the device
specific header file.
Three more macros are made available to modify bits in the Global Configuration Register (GCR) of the
protection gasket for the corresponding block. In contrast to the earlier ones, these macros receive the base
address of the corresponding block (usually named <block_name>_BASEADDRESS) as a parameter.
SET_HARDLOCK(base)
Sets the Hard Lock Bit HLB in the GCR register associated with the module identified by the given base
address <base>.
USER_ACCESS_FORBIDDEN(base)
40-10
PXS20 Microcontroller Reference Manual, Rev. 1
Freescale Semiconductor