AN1528
APPLICATION NOTE
ST92F120/F124/150/F250 TESTFLASH
The testflash is a ST reserved flash area that contains device information, flash parameters and the boot code. This boot code contains the protocol for In-System Programming and the routines for E3TM initialization and management. The testflash is programmed by ST at the factory before shipping and cannot be erased or programmed in user mode.
The purpose of this document is to give an sufficiently accurate description of the testflash content to allow the user to access to the different parameters and routines included in the testflash.
After an overview of the testflash content, the document describes the different routines that can be called at any time by the user code. The last part of this document provides guidelines on the way to handle an E3TM failure.
The terms, abbreviations and acronyms used in this document are listed below and described in alphabetical order.
–CONFxR: CONFiguration x Register
–NVAPR: Non Volatile Access Protection Register
–NVCSSx: NV Complementary Sector Status x
–NVESPx: NV Emulation Status Pointer x
–NVPWDx: Non Volatile PassWorD x
–NVWPR: Non Volatile Write Protection Register
–REDxR: REDundancy x Register
–VCSSx: Volatile Complementary Sector Status x
–VESPx: Volatile Emulation Status Pointer x
Rev. 3.0
AN1528/0105 |
1/18 |
1
Table of Contents
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 GLOSSARY AND ACRONYMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 OVERVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.1 VECTOR TABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1.1 Device identifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.1.2 Testflash code revision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 USER OTP AREA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.3 PROTECTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3 ROUTINES DESCRIPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.1 POWER-ON ROUTINE (230020H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.2 NON MASKABLE INTERRUPT ROUTINE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.3 CODE UPDATE ROUTINE: IN-SYSTEM PROGRAMMING . . . . . . . . . . . . . . . . 8
3.4 E3TM INITIALIZATION ROUTINE (230026H) . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.5 E3TM SWAP ERROR ROUTINES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.5.1 Find Wrong Pages (230029h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.5.2 Find Wrong Bytes (23002Ch) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.5.3 Complete Aborted Swap (23002Fh) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.6 E3TM RESET TO DELIVERY STATUS (230032H) . . . . . . . . . . . . . . . . . . . . . . 14 3.7 USER ROUTINE FOR EXTERNAL WATCHDOG REFRESH . . . . . . . . . . . . . . 15
4 E3TM FAILURE RECOVERY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.1 ERASE OR WRITE ERROR: FATAL ERROR . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.2 SWAP ERROR: NON FATAL ERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2.1 Generate a reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.2.2 Call the “complete aborted swap phase” routine in testflash. . . . . . . . . . . 17
2/18
1
ST92F120/F124/150/F250 TESTFLASH
The structure of the TestFlash content is shown by the following figure:
Figure 1. ST9 TestFlash content
230000h
230020h
230023h
230026h
230029h
23002Ch
23002Fh
230032h
230035h
230E80h
231E80h
231F78h
231F80h
231FFCh
Vector Table
Power-On
routine
Code Update routine (in-system programming)
SCI Interrupt
routines
E3TM Initialization
E3TM
Management
routines
E3TM Swap Error:
Find Wrong Pages
E3TM Swap Error:
Find Wrong Bytes in given Page
E3TM Swap Error: Complete aborted Swap phase
E3TM Reset
to delivery status
Not Used
(4 Kbytes)
Reserved for Testing (248 bytes)
Otp area 124 bytes
Protections
3/18
2
ST92F120/F124/150/F250 TESTFLASH
The first 16 words of the TestFlash contain the Vector Table.
The Power-On Vector is read when exiting from Reset. The Monitor Vector is read in Embedded Emulation Mode after an ETRAP instruction or an external Break. The NMI Vector is read if a Non Maskable Interrupt occurs. The SCI Interrupt Vectors are used for the In-System Programming routine.
Figure 2. Vector Table
Vector Table
230000h |
Power-On Vector |
|
230002h |
||
Monitor Vector |
||
230004h |
||
NMI Vector |
||
230006h |
||
Mask Set Number |
||
230008h |
||
Device Identifier |
||
23000Ah |
||
TestFlash Code Revision |
||
|
||
230010h |
|
|
SCI Error Vector |
||
230012h |
||
SCI Address Match Vector |
||
230014h |
||
SCI Receiving End Vector |
||
230016h |
||
SCI Transmitting End Vector |
||
|
This identifier contains the information about the device, its flash size and its reset vector location.
The CheckSum is the sum of all the bytes from 230000h to 230E77h, it can be used to verify if the actual TestFlash content is the most recent one, or if the TestFlash content is corrupted.
|
|
|
rev 2.6 |
rev 2.7 |
rev 2.7.1 |
|||
|
Flash |
Device ID |
TF rev |
Testflash |
TF rev |
Testflash |
TF rev |
Testflash |
Device |
(23000 |
(23000 |
(23000 |
|||||
|
size |
(230008h) |
Ah) |
checksum |
Ah) |
checksum |
Ah) |
checksum |
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
ST92F124/F150 |
64K |
1024h |
xx26h |
933BFh |
xx27h |
8FC55h |
0127h |
8FBEBh |
|
|
|
|
|
|
|
|
|
ST92F124/F150 |
128K |
1080h |
xx26h |
9341Bh |
xx27h |
8FCB1h |
0127h |
8FC47h |
|
|
|
|
|
|
|
|
|
ST92F250 |
256K |
1100h |
xx26h |
9339Ch |
xx27h |
8FC32h |
0127h |
8FBC8h |
|
|
|
|
|
|
|
|
|
The 124 bytes of TestFlash from 231F80h to 231FFBh are available to the User application as One Time Programmable area (not erasable).
4/18
ST92F120/F124/150/F250 TESTFLASH
The TestFlash locations shown by the following figure have a special meaning related to the Access and Write Flash Protection features (refer to the datasheets).
Figure 3. Protection Map
|
Protection |
|
|
|
|
231FFCh |
NVAPR |
|
231FFDh |
NVWPR |
|
231FFEh |
NVPWD0 |
|
231FFFh |
NVPWD1 |
|
|
|
|
5/18
ST92F120/F124/150/F250 TESTFLASH
Inputs: None.
Outputs: R0, R1.
Variables: R2-R47, R160-R223 (for Stack).
Goal: to perform the initializations of ST9 device (Boot Code).
The Power-On routine is executed automatically when exiting reset.
The Power-On routine performs the following operations:
■initialize the Stack Pointer in the Register File (for this reason, this routine modifies the Registers of group A, B, C and D).
■call the “E3TM Initialization routine“ (230026h).
■initialize the MMU paged registers as shown by the following table.
Table 1. MMU Registers Initialization
Register |
Value |
Seg |
Notes |
|
|
|
|
DPR0 - R240 |
00h |
0h |
1st 16k-page |
|
|
|
|
DPR1 - R241 |
01h |
0h |
2nd 16k-page |
|
|
|
|
DPR2 - R242 |
02h |
0h |
3rd 16k-page |
|
|
|
|
DPR3 - R243 |
80h |
20h |
1st 16k-page |
|
|
|
|
ISR - R248 |
00h |
0h |
|
|
|
|
|
DMASR - R249 |
20h |
20h |
|
|
|
|
|
MPSR - R250 |
21h |
21h |
|
|
|
|
|
MDPR0 - R251 |
84h |
21h |
1st 32k-page |
|
|
|
|
MDPR1 - R252 |
86h |
21h |
2nd 32k-page |
|
|
|
|
■Set bit MEMSEL (bit 4) in the R246 (EMR2) register page 21
■Set the Register Page Pointer to page 0.
■Set Group 0 as working registers.
■Set Program Memory.
■read in 000000h the first word of segment 0h (Flash Memory), that is interpreted as the Power-On Vector of the User application. (Warning: if the device identifier is equal to 0080h, the User Reset Vector is read in 01E000h instead of in 000000h).
6/18