AN2690 Freescale Semiconductor / Motorola, AN2690 Datasheet - Page 3

no-image

AN2690

Manufacturer Part Number
AN2690
Description
Low Frequency EEPROM Emulation on the MC68HLC908QY4
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Method 1 — Reset Forced at Start of Main Loop
MOTOROLA
NOTE:
Low Frequency EEPROM Emulation on the MC68HLC908QY4
This is the simpler of the two methods, because the reset is always forced at
the start of the main loop. The application example in the appendix uses this
method; it forces the reset using an illegal opcode (STOP Instruction used to
generate an Illegal Opcode Reset); see the appendix for specific details.
Figure 1
runs from the internal RC (IRC) oscillator. The code performs some common
initialization tasks, which could include setting up ports and peripheral
configuration.
The code then checks for a Power On Reset (POR) condition, by reading the
SRSR. If the POR flag is set, the code executes the POR initialization, before
enabling and switching to the crystal clock source. If a 32768 Hz crystal is used,
switching to the external clock takes a relatively long time, as the crystal
requires up to 4096 cycles to stabilize.
Alternatively, if an illegal opcode (ILOP) was detected, the code performs some
specific initialization to restore the registers to the values prior to the reset. The
ProgEE flag is then checked and; if it is set, the EEPROM is then programmed
(see application note AN2346: “EEPROM Emulation using FLASH in
MC68HC908QY/QT”), the ProgEE Flag is cleared to indicate programming
was a success, the external crystal is enabled, and, finally, the main loop is
entered.
If another reset condition was detected or the ProgEE flag is clear, the code
jumps to the specific service routine, before switching to the external crystal
and entering the main loop.
Each iteration of the loop checks the status of the ProgEE flag, to see if
programming is to be performed, and then forces a reset, as required. This flag
could be set by an external condition (for example, a switch or IRQ).
In this application, the decision to program EEPROM is always taken at the
start of the loop. Thus, when the code starts up from the forced reset, it starts
executing at the same part of the code, once initialization is complete. There is
a latency from the event signalling to program EEPROM to the array being
programmed. The maximum latency equals the maximum loop iteration + time
to force reset + reset time and recovery + initialization + program time. The
example application gives a typical time for this latency.
It could be necessary to save critical variables and/or internal registers before
forcing the reset, and to restore this setup information when the MCU comes
out of reset. This can be accomplished by storing the variables on the stack.
Method 2 demonstrates this.
Freescale Semiconductor, Inc.
For More Information On This Product,
shows a basic flow diagram of the operation. Out of reset, the MCU
Go to: www.freescale.com
Method 1 — Reset Forced at Start of Main Loop
AN2690
3

Related parts for AN2690