3 - F021_Flash_API_License_Agreements
F021 Flash API Library Code Software License Agreement IMPORTANT – PLEASE CAREFULLY READ THE FOLLOWING LICENSE AGREEMENT, WHICH IS LEGALLY BINDING. AFTER YOU READ THIS
LICENSE AGREEMENT, YOU WILL BE ASKED WHETHER YOU ACCEPT AND AGREE TO ITS TERMS. DO NOT CLICK “I ACCEPT” UNLESS:
(1) YOU WILL USE THE LICENSED MATERIALS FOR YOUR OWN BENEFIT AND PERSONALLY ACCEPT, AGREE TO AND INTEND TO BE
BOUND BY THESE TERMS; OR (2) YOU ARE AUTHORIZED TO, AND INTEND TO BE BOUND BY, THESE TERMS ON BEHALF OF YOUR
COMPANY.
Important – Read carefully: This Software License Agreement (“
Agreement”) is a legal agreement between you and
Texas Instruments Incorporated (“
TI”). In this Agreement “you” means you personally if you will exercise the rights granted
for your own benefit, but it means your company (or you on behalf of your company) if you will exercise the rights granted
for your company’s benefit. The “
Licensed Materials” subject to this Agreement include the software programs and any
associated electronic documentation (in each case, in whole or in part), that accompany this Agreement and you access
“on-line”, as well as any updates or upgrades to such software programs or documentation, if any, provided to you at TI’s
sole discretion. The Licensed Materials are specifically designed and licensed for use solely and exclusively with
semiconductor devices manufactured by or for TI (“
TI Devices”). By installing, copying or otherwise using the Licensed
Materials you agree to abide by the provisions set forth herein. This Agreement is displayed for you to read prior to using
the Licensed Materials. If you choose not to accept or agree with these provisions, do not download or install the Licensed
Materials.
1. License Grant and Use Restrictions. a.
Licensed Materials License Grant. Subject to the terms of this Agreement, TI hereby grants to you a limited,
non-transferable, non-exclusive, non-assignable, non-sub-licensable, fully paid-up and royalty-free license to:
i. Object Code Evaluation, Testing and Use License: make copies, display internally, distribute internally and
use internally the Licensed Materials in object code for the sole purposes of evaluating and testing the Licensed
Materials and designing and developing Licensee Products, and maintaining and supporting the Licensee
Products. For purposes of this Agreement, “
Licensee Product” means a product that consists of both: (i)
hardware, including one or more TI Devices, and (ii) software components, including only executable versions of
the Licensed Materials that execute solely and exclusively on such TI Devices;
ii. Demonstration License: demonstrate to third parties the Licensed Materials executing solely and exclusively
on TI Devices as they are used in Licensee Products, provided that such Licensed Materials are demonstrated in
object or executable versions only and
iii. Production and Distribution License: make, use, import, export and otherwise distribute the Licensed
Materials as part of a Licensee Product, provided that such Licensee Products include only embedded
executable copies of such Licensed Materials that execute solely and exclusively on TI Devices.
b. Contractors. The licenses granted to you hereunder shall include your on-site and off-site contractors (either an
individual or entity), while such contractors are performing work for or providing services to you, provided that such
contractors have executed work-for-hire agreements with you containing applicable terms and conditions consistent
with the terms and conditions set forth in this Agreement and provided further that you shall be liable to TI for any
breach by your contractors of this Agreement to the same extent as you would be if you had breached the
Agreement yourself.
c. No Other License. Nothing in this Agreement shall be construed as a license to any intellectual property rights of
TI other than those rights embodied in the Licensed Materials provided to you by TI. EXCEPT AS PROVIDED
HEREIN, NO OTHER LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY OTHER TI
INTELLECTUAL PROPERTY RIGHTS IS GRANTED HEREIN.
Page 1 of 5
Flash API Click-Wrap (May 2014)
d. Covenant not to Sue. During the term of this Agreement, you agree not to assert a claim against TI or its
licensees that the Licensed Materials infringe your intellectual property rights.
e. Restrictions. You shall not use the Licensed Materials with a processing device other than a TI Device, and you
agree that any such unauthorized use of the Licensed Materials is a material breach of this Agreement. You shall
not use the Licensed Materials for the purpose of analyzing or proving infringement of any of your patents by either
TI or TI’s customers. Except as expressly provided in this Agreement, you shall not copy, publish, disclose, display,
provide, transfer or make available the Licensed Materials to any third party and you shall not sublicense, transfer, or
assign the Licensed Materials or your rights under this Agreement to any third party. You shall not mortgage, pledge
or encumber the Licensed Materials in any way. You may use the Licensed Materials with Open Source Software or
with software developed using Open Source Software tools provided you do not incorporate, combine or distribute
the Licensed Materials in a manner that subjects the Licensed Materials to any license obligations or any other
intellectual property related terms of any license governing such Open Source Software. "
Open Source Software"
means any software licensed under terms requiring that (A) the software provided under this Agreement
(“
Proprietary Software”) incorporated, combined or distributed with such software or developed using such
software: (i) be disclosed or distributed in source code form; or (ii) otherwise be licensed on terms inconsistent with
the terms of this Agreement, including but not limited to permitting use of the Proprietary Software on or with devices
other than TI Devices, or (B) require the owner of Proprietary Software to license any of its patents to users of the
Open Source Software and/or Proprietary Software incorporated, combined or distributed with such Open Source
Software or developed using such Open Source Software.
f. Termination
. This Agreement is effective on the date the Licensed Materials are delivered to you together with
this Agreement and will remain in full force and effect until terminated. You may terminate this Agreement at any
time by written notice to TI. Without prejudice to any other rights, if you fail to comply with the terms of this
Agreement or you are acquired, TI may terminate your right to use the Licensed Materials upon written notice to you.
Upon termination of this Agreement, you will destroy any and all copies of the Licensed Materials in your possession,
custody or control and provide to TI a written statement signed by your authorized representative certifying such
destruction. Except for Sections 1(a), 1(b) and 1(d), all provisions of this Agreement shall survive termination of this
Agreement.
2. Licensed Materials Ownership. The Licensed Materials are licensed, not sold to you, and can only be used in
accordance with the terms of this Agreement. Subject to the licenses granted to you pursuant to this Agreement, TI,
and its licensors, own and shall continue to own all right, title and interest in and to the Licensed Materials, including
all copies thereof. You agree that all fixes, modifications and improvements to the Licensed Materials conceived of
or made by TI that are based, either in whole or in part, on your feedback, suggestions or recommendations are the
exclusive property of TI and all right, title and interest in and to such fixes, modifications or improvements to the
Licensed Materials will vest solely in TI. Moreover, you acknowledge and agree that when your independently
developed software or hardware components are combined, in whole or in part, with the Licensed Materials, your
right to use the combined work that includes the Licensed Materials remains subject to the terms and conditions of
this Agreement.
3. Intellectual Property Rights. a. The Licensed Materials contain copyrighted material, trade secrets and other proprietary information of TI and its
licensors and are protected by copyright laws, international copyright treaties, and trade secret laws, as well as other
intellectual property laws. To protect TI’s and its licensors’ rights in the Licensed Materials, you agree, except as
specifically permitted by statute by a provision that cannot be waived by contract, not to “unlock”, decompile, reverse
engineer, disassemble or otherwise translate to a human-perceivable form any portions of the Licensed Materials
provided to you in object code format only, nor permit any person or entity to do so. You shall not remove, alter,
cover, or obscure any confidentiality, trade secret, trade mark, patent, copyright or other proprietary notice or other
identifying marks or designs from any component of the Licensed Materials and you shall reproduce and include in
all copies of the Licensed Materials the copyright notice(s) and proprietary legend(s) of TI and its licensors as they
appear in the Licensed Materials. TI reserves all rights not specifically granted under this Agreement.
b. Certain Licensed Materials may be based on industry recognized standards or software programs published by
industry recognized standards bodies and certain third parties may claim to own patents, copyrights, and other
intellectual property rights that cover implementation of those standards. You acknowledge and agree that this
Page 2 of 5
Flash API Click-Wrap (May 2014)
Agreement does not convey a license to any such third party patents, copyrights, and other intellectual property
rights and that you are solely responsible for any patent, copyright, or other intellectual property right claim that
relates to your use or distribution of the Licensed Materials or your use or distribution of your products that include or
incorporate the Licensed Materials. Moreover, you acknowledge that you are responsible for any fees or royalties
that may be payable to any third party based on such third party’s interests in the Licensed Materials or any
intellectual property rights that cover implementation of any industry recognized standard, any software program
published by any industry recognized standards bodies or any other proprietary technology.
4. Audit Right. At TI's request, and within thirty (30) calendar days after receiving written notice, you shall permit an
internal or independent auditor selected by TI to have access, no more than once each calendar year (unless the
immediately preceding audit revealed a discrepancy) and during your regular business hours, to all of your
equipment, records, and documents as may contain information bearing upon the use of the Licensed Materials
. You shall keep full, complete, clear and accurate records with respect to product sales and distributions for a period
beginning with the then-current calendar year and going back three (3) years.
5. Confidential Information. You acknowledge and agree that the Licensed Materials contain trade secrets and other
confidential information of TI and its licensors. You agree to use the Licensed Materials solely within the scope of
the licenses set forth herein, to maintain the Licensed Materials in strict confidence, to use at least the same
procedures and degree of care that you use to prevent disclosure of your own confidential information of like
importance but in no instance less than reasonable care, and to prevent disclosure of the Licensed Materials to any
third party, except as may be necessary and required in connection with your rights and obligations hereunder;
provided, however, that you may not provide the Licensed Materials to any business organization or group within
your company or to customers or contractors that design or manufacture semiconductors unless TI gives written
consent. You agree to obtain executed confidentiality agreements with your employees and contractors having
access to the Licensed Materials and to diligently take steps to enforce such agreements in this respect. TI may
disclose your contact information to TI’s licensors.
6. Warranties and Limitations. THE LICENSED MATERIALS ARE PROVIDED “AS IS”. FURTHERMORE, YOU
ACKNOWLEDGE AND AGREE THAT THE LICENSED MATERIALS HAVE NOT BEEN TESTED OR CERTIFIED
BY ANY GOVERNMENT AGENCY OR INDUSTRY REGULATORY ORGANIZATION OR ANY OTHER THIRD
PARTY ORGANIZATION. YOU AGREE THAT PRIOR TO USING, INCORPORATING OR DISTRIBUTING THE
LICENSED MATERIALS IN OR WITH ANY COMMERCIAL PRODUCT THAT YOU WILL THOROUGHLY TEST
THE PRODUCT AND THE FUNCTIONALITY OF THE LICENSED MATERIALS IN OR WITH THAT PRODUCT AND
BE SOLELY RESPONSIBLE FOR ANY PROBLEMS OR FAILURES.
TI AND ITS LICENSORS MAKE NO WARRANTY OR REPRESENTATION, WHETHER EXPRESS, IMPLIED OR
STATUTORY, REGARDING THE LICENSED MATERIALS, INCLUDING BUT NOT LIMITED TO ANY IMPLIED
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT
OF ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADE SECRETS OR OTHER INTELLECTUAL PROPERTY
RIGHTS. YOU AGREE TO USE YOUR INDEPENDENT JUDGMENT IN DEVELOPING YOUR PRODUCTS.
NOTHING CONTAINED IN THIS AGREEMENT WILL BE CONSTRUED AS A WARRANTY OR
REPRESENTATION BY TI TO MAINTAIN PRODUCTION OF ANY TI SEMICONDUCTOR DEVICE OR OTHER
HARDWARE OR SOFTWARE WITH WHICH THE LICENSED MATERIALS MAY BE USED.
IN NO EVENT SHALL TI OR ITS LICENSORS, BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
PUNITIVE OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED, ON ANY THEORY OF LIABILITY, IN
CONNECTION WITH OR ARISING OUT OF THIS AGREEMENT OR THE USE OF THE LICENSED MATERIALS
REGARDLESS OF WHETHER TI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. EXCLUDED
DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF REMOVAL OR REINSTALLATION, OUTSIDE
COMPUTER TIME, LABOR COSTS, LOSS OF DATA, LOSS OF GOODWILL, LOSS OF PROFITS, LOSS OF
SAVINGS, OR LOSS OF USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI’S OR ITS
LICENSORS’ AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF YOUR USE OF THE
LICENSED MATERIALS EXCEED FIVE HUNDRED U.S. DOLLARS (US$500).
Because some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages or
limitation on how long an implied warranty lasts, the above limitations or exclusions may not apply to you.
Page 3 of 5
Flash API Click-Wrap (May 2014)
7. Indemnification Disclaimer. YOU ACKNOWLEDGE AND AGREE THAT TI SHALL NOT BE LIABLE FOR AND
SHALL NOT DEFEND OR INDEMNIFY YOU AGAINST ANY THIRD PARTY INFRINGEMENT CLAIM THAT
RELATES TO OR IS BASED ON YOUR MANUFACTURE, USE, OR DISTRIBUTION OF THE LICENSED
MATERIALS OR YOUR MANUFACTURE, USE, OFFER FOR SALE, SALE, IMPORTATION OR DISTRIBUTION OF
YOUR PRODUCTS THAT INCLUDE OR INCORPORATE THE LICENSED MATERIALS.
8. No Technical Support. TI and its licensors are under no obligation to install, maintain or support the Licensed
Materials.
9. Notices. All notices to TI hereunder shall be delivered to Texas Instruments Incorporated, 12500 TI Boulevard, Mail
Station 8638, Dallas, Texas 75243, Attention: Contracts Manager – Embedded Processing, with a copy to Texas
Instruments Incorporated, 13588 N. Central Expressway, Mail Station 3999, Dallas, Texas 75243, Attention: Law
Department – Embedded Processing. All notices shall be deemed served when received by TI.
10.
Export Control. The Licensed Materials are subject to export control under the U.S. Commerce Department’s Export
Administration Regulations (“
EAR”). Unless prior authorization is obtained from the U.S. Commerce Department, neither
you nor your subsidiaries shall export, re-export, or release, directly or indirectly (including, without limitation, by
permitting the Licensed Materials to be downloaded), any technology, software, or software source code, received from
TI, or export, directly or indirectly, any direct product of such technology, software, or software source code, to any
person, destination or country to which the export, re-export, or release of the technology, software, or software source
code, or direct product is prohibited by the EAR. You represent and warrant that you (i) are not located in, or under the
control of, a national or resident of Cuba, Iran, North Korea, Sudan and Syria or any other country subject to a U.S.
goods embargo; (ii) are not on the U.S. Treasury Department’s List of Specially Designated Nationals or the U.S.
Commerce Department’s Denied Persons List or Entity List; and (iii) will not use the Licensed Materials or transfer the
Licensed Materials for use in any military, nuclear, chemical or biological weapons, or missile technology end-uses. Any
software export classification made by TI shall not be construed as a representation or warranty regarding the proper
export classification for such software or whether an export license or other documentation is required for the
exportation of such software.
11.
Governing Law and Severability; Waiver. This Agreement will be governed by and interpreted in accordance with
the laws of the State of Texas, without reference to conflict of laws principles. If for any reason a court of competent
jurisdiction finds any provision of the Agreement to be unenforceable, that provision will be enforced to the maximum
extent possible to effectuate the intent of the parties, and the remainder of the Agreement shall continue in full force
and effect. This Agreement shall not be governed by the United Nations Convention on Contracts for the
International Sale of Goods, or by the Uniform Computer Information Transactions Act (UCITA). The parties agree
that non-exclusive jurisdiction for any dispute arising out of or relating to this Agreement lies within the courts located
in the State of Texas. Notwithstanding the foregoing, any judgment may be enforced in any United States or foreign
court, and either party may seek injunctive relief in any United States or foreign court. Failure by TI to enforce any
provision of this Agreement shall not be deemed a waiver of future enforcement of that or any other provision in this
Agreement or any other agreement that may be in place between the parties.
12. PRC Provisions. If you are located in the People’s Republic of China (“
PRC”) or if the Licensed Materials will be
sent to the PRC, the following provisions shall apply:
a.
Registration Requirements. You shall be solely responsible for performing all acts and obtaining all approvals
that may be required in connection with this Agreement by the government of the PRC, including but not limited to
registering pursuant to, and otherwise complying with, the PRC Measures on the Administration of Software
Products, Management Regulations on Technology Import-Export, and Technology Import and Export Contract
Registration Management Rules. Upon receipt of such approvals from the government authorities, you shall forward
evidence of all such approvals to TI for its records. In the event that you fail to obtain any such approval or
registration, you shall be solely responsible for any and all losses, damages or costs resulting therefrom, and shall
indemnify TI for all such losses, damages or costs.
b.
Governing Language. This Agreement is written and executed in the English language and shall be
authoritative and controlling, whether or not translated into a language other than English to comply with law or for
reference purposes. If a translation of this Agreement is required for any purpose, including but not limited to
Page 4 of 5
Flash API Click-Wrap (May 2014)
registration of the Agreement pursuant to any governmental laws, regulations or rules, you shall be solely
responsible for creating such translation.
13.
Contingencies. TI shall not be in breach of this Agreement and shall not be liable for any non-performance or
delay in performance if such non-performance or delay is due to a force majeure event or other circumstances
beyond TI’s reasonable control.
14.
Entire Agreement. This is the entire agreement between you and TI and this Agreement supersedes any prior
agreement between the parties related to the subject matter of this Agreement. Notwithstanding the foregoing, any
signed and effective software license agreement relating to the subject matter hereof and stating expressly that such
agreement shall control regardless of any subsequent click-wrap, shrink-wrap or web-wrap, shall supersede the
terms of this Agreement. No amendment or modification of this Agreement will be effective unless in writing and
signed by a duly authorized representative of TI. You hereby warrant and represent that you have obtained all
authorizations and other applicable consents required empowering you to enter into this Agreement.
Page 5 of 5
Flash API Click-Wrap (May 2014)
Document Outline
9 - SPNA148s
Application ReportSPNA148 – May 2013Advanced F021 Flash API Erase/Program UsageJohn R. HallABSTRACTThis application report gives the user of the F021 Flash API the ability to write program and erase code in
a way that is optimized to their applications.
Contents1
Introduction ..................................................................................................................
22
Flash Registers Used .......................................................................................................
23
Example Usage .............................................................................................................
54
References .................................................................................................................
11List of Figures1
Flash Address Register (FADDR) [offset = FFF8 7110h]..............................................................
22
Flash Wide Programming Write Data Register (FWPWRITE0) [offset = FFF8 7120h] ............................
33
Flash Wide Programming Write Data Register (FWPWRITE1) [offset = FFF8 7124h] ............................
34
Flash Wide Programming Write Data Register (FWPWRITE2) [offset = FFF8 7128h] ............................
35
Flash Wide Programming Write Data Register (FWPWRITE3) [offset = FFF8 712Ch] ...........................
36
Flash Wide Programming Write Data Register (FWPWRITE4) [offset = FFF8 7130h] ............................
37
Flash Wide Programming Write Data Register (FWPWRITE5) [offset = FFF8 7134h] ............................
38
Flash Wide Programming Write Data Register (FWPWRITE6) [offset = FFF8 7138h] ............................
39
Flash Wide Programming Write Data Register (FWPWRITE7) [offset = FFF8 713Ch] ...........................
310
Flash Wide Programming Write Data ECC Register - 288-Bit Bank (FWPWRITE_ECC) [offset = FFF8
7140h] ........................................................................................................................
411
Flash Wide Programming Write Data ECC Register - 144-Bit Bank (FWPWRITE_ECC) [offset = FFF8
7140h] ........................................................................................................................
412
Flash Wide Programming Write Data ECC Register - 72-Bit Bank (FWPWRITE_ECC) [offset = FFF8
7140h] ........................................................................................................................
413
Flash State Machine Command Register (FSM_COMMAND) [offset = FFF8 720Ch] ............................
514
Flash State Machine Command Execute Register (FSM_EXECUTE) [offset = FFF8 72B4h] ...................
515
Recommended Command Execution Flow..............................................................................
7List of Tables1
Additional Flash Control Registers .......................................................................................
22
Flash Address Register (FADDR) Field Descriptions ..................................................................
23
Flash Wide Programming Write Data Register (FWPWRITE0) Field Descriptions ................................
44
Flash Wide Programming Write Data ECC Register (FWPWRITE_ECC) Field Descriptions ....................
45
Flash State Machine Command Register (FSM_COMMAND) Field Descriptions .................................
56
Flash State Machine Command Register (FSM_COMMAND) Field Descriptions .................................
5All trademarks are the property of their respective owners.
SPNA148 – May 2013
Advanced F021 Flash API Erase/Program Usage1
Submit Documentation FeedbackCopyright © 2013, Texas Instruments Incorporated
Introductionwww.ti.com1IntroductionThe 65nm Flash Technology used on Hercules devices generally requires the use of the F021 Flash API
to do program and erase operations. Since these functions need to cover all possible uses, they are
generic, and not the most efficient functions available for all applications. Therefore, this document is
designed to allow the user to write erase and program functions that are optimized for their application
needs. The F021 Flash API is still required for Flash initialization and bank selection. For recommended
erase and program operation flows, see the
F021 Flash API Reference Guide (SPNU501).NOTE: This document applies to all versions of the F021 Flash API starting with v2.00.00.2Flash Registers UsedIn addition to the registers listed in the
F021 Flash Module chapter in the device-specific technical
reference manual,
Table 1 lists registers specifically needed for program and erase operations.
Table 1. Additional Flash Control RegistersOffsetAcronymRegister DescriptionSectionFFF8 7110
FADDR
The absolute address of the data that the CPU would use to
Section 2.1access the location.
FFF8 7120
FWPWRITE0
WPDATA[31: 00]
Section 2.2FFF8 7124
FWPWRITE1
WPDATA[63:32]
Section 2.2FFF8 7128
FWPWRITE2
WPDATA[95:64]
Section 2.2FFF8 712C
FWPWRITE3
WPDATA[127:96]
Section 2.2FFF8 7130
FWPWRITE4
WPDATA[159:128]
Section 2.2FFF8 7134
FWPWRITE5
WPDATA[191:160]
Section 2.2FFF8 7138
FWPWRITE6
WPDATA[223:192]
Section 2.2FFF8 713C
FWPWRITE7
WPDATA[255:224]
Section 2.2FFF8 7140
FWPWRITE_ECC
Contains the ECC bits for the FWPWRITE7:0 registers
Section 2.3FFF8 720C
FSM_COMMAND
The command to be executed
Section 2.4FFF8 72B4
FSM_EXECUTE
Execute the command in the FSM_COMMAND register
Section 2.52.1Flash Address Register (FADDR)This register contains the absolute address of the location to be programmed, or area to be erased. For
FSM operations, this register can contain the main Flash, data Flash or Customer OTP addresses. The
ECC regions at 0xF01x_xxxx or 0xF02x_xxxx are illegal regions because the ECC programs must be
done using the address of the data that ECC protects and the FWPWRITE_ECC register. FADDR is used
by Program and Erase commands.
The Flash address register is shown in
Figure 1 and described in
Table 2.Figure 1. Flash Address Register (FADDR) [offset = FFF8 7110h]31
0
ADDR
RWP
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode with FLOCK=any value
Table 2. Flash Address Register (FADDR) Field DescriptionsBitFieldValueDescription31:0
ADDR
CPU address to be
Absolute address of the data that the CPU would use to access the location.
operated on by the
command
2
Advanced F021 Flash API Erase/Program UsageSPNA148 – May 2013
Submit Documentation FeedbackCopyright © 2013, Texas Instruments Incorporated
www.ti.comFlash Registers Used2.2Flash Wide Programming Write Data Register (FWPWRITE0-7)The Flash wide programming write data register is shown in
Figure 2 through
Figure 9 and described in
Table 3.
Figure 2. Flash Wide Programming Write Data Register (FWPWRITE0) [offset = FFF8 7120h]31
0
WPDATA[31:00]
RWP
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode
Figure 3. Flash Wide Programming Write Data Register (FWPWRITE1) [offset = FFF8 7124h]31
0
WPDATA[63:32]
RWP
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode
Figure 4. Flash Wide Programming Write Data Register (FWPWRITE2) [offset = FFF8 7128h]31
0
WPDATA[95:64]
RWP
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode
Figure 5. Flash Wide Programming Write Data Register (FWPWRITE3) [offset = FFF8 712Ch]31
0
WPDATA[127:96]
RWP
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode
Figure 6. Flash Wide Programming Write Data Register (FWPWRITE4) [offset = FFF8 7130h]31
0
WPDATA[159:128]
RWP
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode
Figure 7. Flash Wide Programming Write Data Register (FWPWRITE5) [offset = FFF8 7134h]31
0
WPDATA[191:160]
RWP
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode
Figure 8. Flash Wide Programming Write Data Register (FWPWRITE6) [offset = FFF8 7138h]31
0
WPDATA[223:192]
RWP
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode
Figure 9. Flash Wide Programming Write Data Register (FWPWRITE7) [offset = FFF8 713Ch]31
0
WPDATA[255:224]
RWP
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode
SPNA148 – May 2013
Advanced F021 Flash API Erase/Program Usage3
Submit Documentation FeedbackCopyright © 2013, Texas Instruments Incorporated
Flash Registers Usedwww.ti.comTable 3. Flash Wide Programming Write Data Register (FWPWRITE0) Field DescriptionsBitFieldValueDescription255:0
WPDATA
Data to be
This register contains the data to program into the flash memory. Each write will set data bits and
[255:0]
programmed
another internal
byte enable bit for each byte to be written by the FSM. The FWPWRITE register is
set to all ones after writing to the FADDR register or when the FSM completes an operation.
For 128-144-bit banks, only FWPWRITE0-3 are used during programming. FWPWRITE4-7 are
unused. For 64-72-bit banks, use only FWPWRITE0-1 are used during programming.
Unused bits can be written and read but they will not be part of the bank operations.
NOTE:Do not write to this register while a FSM operation is active.
2.3Flash Wide Programming Write Data ECC Register (FWPWRITE_ECC)The Flash wide programming write ECC register is shown in
Figure 10 through
Figure 12 and
described in
Table 4.Figure 10. Flash Wide Programming Write Data ECC Register - 288-Bit Bank (FWPWRITE_ECC)[offset = FFF8 7140h]31
24 23
16 15
8
7
0
ECC for Bytes 7:0
ECC for Bytes 15:8
ECC for Bytes 23:16
ECC for Bytes 31:24
RWP
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode with FLOCK=any value
Figure 11. Flash Wide Programming Write Data ECC Register - 144-Bit Bank (FWPWRITE_ECC)[offset = FFF8 7140h]31
24 23
16 15
0
ECC for Bytes 7:0
ECC for Bytes 15:8
Reserved
RWP
RWP=FF
FF_FFFF
h
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode with FLOCK=any value
Figure 12. Flash Wide Programming Write Data ECC Register - 72-Bit Bank (FWPWRITE_ECC)[offset = FFF8 7140h]31
24 23
0
ECC for Bytes 7:0
Reserved
RWP
RWP=FFF
F_FFFFh
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode with FLOCK=any value
Table 4. Flash Wide Programming Write Data ECC Register (FWPWRITE_ECC) Field DescriptionsBitFieldValueDescription31:0
ECC
ECC Data to be
This register contains the ECC bits for the FWPWRITE7:0 registers. The location of the ECC
[31:0]
programmed
bits corresponding to the data depends on the device configuration. The three supported
configurations are shown above.
Unused bits can be written and read but they will not be part of the bank operations.
This register is an extension of the FWPWRITE register. Do not write to this register while a
FSM operation is active. This register is set to all ones just like the FWPWRITEx registers.
4
Advanced F021 Flash API Erase/Program UsageSPNA148 – May 2013
Submit Documentation FeedbackCopyright © 2013, Texas Instruments Incorporated
www.ti.comExample Usage2.4Flash State Machine Command Register (FSM_COMMAND)The Flash state machine command register is shown in
Figure 13 and described in
Table 5.
Figure 13. Flash State Machine Command Register (FSM_COMMAND) [offset = FFF8 720Ch]31
6
5
4
3
2
1
0
Reserved
FSM_CMD
R-0
RWP
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode
Table 5. Flash State Machine Command Register (FSM_COMMAND) Field DescriptionsBitFieldValueDescription31:6
Reserved
0
These are reserved bits
5:0
FSM_CMD
Refer to the supported commands listed in Appendix A of
F021 Flash API Reference Guide
(
SPNU501). Writes to this register are blocked if the state machine is busy. The only
exception is to write the suspend command.
2.5Flash State Machine Command Execute Register (FSM_EXECUTE)The Flash state machine command execute register is shown in
Figure 14 and described in
Table 6.
Figure 14. Flash State Machine Command Execute Register (FSM_EXECUTE) [offset = FFF8 72B4h]31
20
19
18
17
16
Reserved
SUSPEND_NOW
R-0
RWP-1010
15
5
4
3
2
1
0
Reserved
FSMEXECUTE
R-0
RWP-01010
LEGEND: -
n = value after reset, R=Read, WP=Write in Privilege Mode
Table 6. Flash State Machine Command Register (FSM_COMMAND) Field DescriptionsBitFieldValueDescription31:20
Reserved
0
These are reserved bits
19:16
SUSPEND_NOW
0101
Writing a 5 to this register will suspend the Program or Erase sector command. Writes to
this register are ignored unless the FSM is busy with one of these commands. This field
resets to ‘1010’ when the FSM enters the standby state where it waits for the next
command. It will not retain the written value for long. The Bank erase command and every
command except those two commands above are not suspendable and will ignore the
suspend command. A suspend operation will exit the FSM with the proper setup and hold
times for the various modes.
15:5
Reserved
0
These are reserved bits
4:0
FSMEXECUTE
01010
To invoke a FSM command this register must be written with a value of 10101. This register
is reset back to 01010 by the FSM upon completion of the command operation. Writes to
this register are ignored while the FSM is busy. All others registers must be set up before
writing to this command. Writing a 15h to this field is the last step to starting an FSM
operation.
3Example UsageThe following examples show some typically use cases in writing code using the Flash Memory Controller
registers. The example code segments make use of the following framework code. For API functions used
in these examples, see the
F021 Flash API Reference Guide (
SPNU501). For proper initialization of the
device prior to any Flash operations, see the device-specific initialization document. All FMC register
writes require the device to be in a privilege state.
SPNA148 – May 2013
Advanced F021 Flash API Erase/Program Usage5
Submit Documentation FeedbackCopyright © 2013, Texas Instruments Incorporated
Example Usagewww.ti.com#include “F021.h”
int main (void)
{
Fapi_StatusType oReturnCheck = Fapi_Status_Success;
FwpWriteByteAccessorType
* oFwpWriteByteAccessor
= FWPWRITE_BYTE_ACCESSOR_ADDRESS;
FwpWriteByteAccessorType
* oFwpWriteEccByteAccessor = FWPWRITE_ECC_BYTE_ACCESSOR_ADDRESS;
FwpWriteDWordAccessorType * oFwpWriteDWordAccessor
= FWPWRITE_DWORD_ACCESSOR_ADDRESS;
uint8 au8MainDataBuffer[16] = {0x78, 0x17, 0x19, 0x2E, 0x0A, 0xB9, 0x11, 0x70,
0x5F, 0xC1, 0x9C, 0xFD, 0x54, 0x51, 0xED, 0x86};
uint32 u32Index;
/*
For proper initialization of the device prior to any Flash
operations,
see the device-specific initialization document.
Assumes, unless otherwise noted, device has 144bit wide Flash Banks.
*/
oReturnCheck = Fapi_initializeFlashBanks(180);
/* Example code is assuming operating
frequency of 180 MHz */
if((oReturnCheck == Fapi_Status_Success) &&
(FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.Busy != Fapi_Status_FsmBusy))
{
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
/* Place specific example code here */
/* Wait for FSM to finish */
while(FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.Busy == Fapi_Status_FsmBusy);
/* Check the FSM Status to see if there were no errors */
if (FLASH_CONTROL_REGISTER->FmStat.u32Register != 0)
{
/* Put Error handling code here */
}
}
}
6
Advanced F021 Flash API Erase/Program UsageSPNA148 – May 2013
Submit Documentation FeedbackCopyright © 2013, Texas Instruments Incorporated
www.ti.comExample Usage3.1Typical Command Execution FlowFigure 15 shows the typical flow for issuing an erase or program command.
Start
No
Yes
CHECK_FSM_READY_BUSY ==
Fapi_Status_FsmReadyLoad FSM_COMMAND register field
FSM_CMD with Fapi_ClearStatus
Load FSM_EXECUTE register field
FSM_EXECUTE with 0x15
For Erase and Program commands, load FADDR register with appropriate addressFor Program command, load
FWPWRITEx register(s) with appropriate data valuesLoad FSM_COMMAND register field
FSM_CMD with one of these
commands:
Fapi_ProgramData, Fapi_EraseSector, Fapi_EraseBankLoad FSM_EXECUTE register field
FSM_EXECUTE with 0x15
Done
Figure 15. Recommended Command Execution FlowSPNA148 – May 2013
Advanced F021 Flash API Erase/Program Usage7
Submit Documentation FeedbackCopyright © 2013, Texas Instruments Incorporated
Example Usagewww.ti.com3.2Programming Operations3.2.1Programming a Single ByteThe following code segement will write a single byte to the address specified.
FLASH_CONTROL_REGISTER->Fbprot.u32Register = 1U;
/* Disable Level 1 Protection */
/* Enable all sectors of current bank for erase and program.
For EEPROM banks with more
than 16 sectors, this must be 0xFFFF */
FLASH_CONTROL_REGISTER->Fbse.u32Register = 0xFFFF;
FLASH_CONTROL_REGISTER->Fbprot.u32Register = 0U;
/* Enable Level 1 Protection */
/*Unlock FSM registers for writing */
FLASH_CONTROL_REGISTER->FsmWrEna.u32Register
= 0x5U;
/* Set command to "Clear the Status Register" */
FLASH_CONTROL_REGISTER->FsmCommand.FSM_COMMAND_BITS.FSMCMD = Fapi_ClearStatus;
/* Execute the Clear Status command */
FLASH_CONTROL_REGISTER->FsmExecute.FSM_EXECUTE_BITS.FSMEXECUTE = 0x15U;
/* Write address to FADDR register */
FLASH_CONTROL_REGISTER->Faddr.u32Register = 0x0100U;
/* Placing byte at address 0x0102 */
oFwpWriteByteAccessor[2] = 0xA5;
/* Set command to "Program" */
FLASH_CONTROL_REGISTER->FsmCommand.FSM_COMMAND_BITS.FSMCMD = Fapi_ProgramData;
/* Execute the Program command */
FLASH_CONTROL_REGISTER->FsmExecute.FSM_EXECUTE_BITS.FSMEXECUTE = 0x15U;
/* re-lock FSM registers to prevent writing */
FLASH_CONTROL_REGISTER->FsmWrEna.u32Register
= 0x2U;
3.2.2Programming 128-Bit Data and 16-Bit ECCThe following code segement will write 16 bytes starting at the 128-bit aligned address specified.
FLASH_CONTROL_REGISTER->Fbprot.u32Register = 1U;
/* Disable Level 1 Protection */
/* Enable all sectors of current bank for erase and program.
For EEPROM banks with more
than 16 sectors, this must be 0xFFFF */
FLASH_CONTROL_REGISTER->Fbse.u32Register = 0xFFFF;
FLASH_CONTROL_REGISTER->Fbprot.u32Register = 0U;
/* Enable Level 1 Protection */
/*Unlock FSM registers for writing */
FLASH_CONTROL_REGISTER->FsmWrEna.u32Register
= 0x5U;
/* Set command to "Clear the Status Register" */
FLASH_CONTROL_REGISTER->FsmCommand.FSM_COMMAND_BITS.FSMCMD = Fapi_ClearStatus;
/* Execute the Clear Status command */
FLASH_CONTROL_REGISTER->FsmExecute.FSM_EXECUTE_BITS.FSMEXECUTE = 0x15U;
/* Write address to FADDR register */
FLASH_CONTROL_REGISTER->Faddr.u32Register = 0x0100U;
/* Placing bytes at address 0x0100 - 0x010F */
8
Advanced F021 Flash API Erase/Program UsageSPNA148 – May 2013
Submit Documentation FeedbackCopyright © 2013, Texas Instruments Incorporated
www.ti.comExample Usagefor(u32Index=0;u32Index<16;u32Index++)
{
oFwpWriteByteAccessor[u32Index] = au8MainDataBuffer[u32Index];
}
/* Supply the address where ECC is being calculated */
FLASH_CONTROL_REGISTER->FemuAddr.u32Register
= 0x0100;
#if defined(_LITTLE_ENDIAN)
/* Supply the lower 32bit word */
FLASH_CONTROL_REGISTER->FemuDlsw.u32Register
= oFwpWriteDwordAccessor[1];
/* Supply the upper 32bit word */
FLASH_CONTROL_REGISTER->FemuDmsw.u32Register
= oFwpWriteDwordAccessor[0];
#else
/* Supply the upper 32bit word */
FLASH_CONTROL_REGISTER->FemuDlsw.u32Register
= oFwpWriteDwordAccessor[0];
/* Supply the lower 32bit word */
FLASH_CONTROL_REGISTER->FemuDmsw.u32Register
= oFwpWriteDwordAccessor[1];
#endif
/* Place the Wrapper calculated ECC into FWPWRITE_ECC */
oFwpWriteEccByteAccessor[EI8(0)] = FLASH_CONTROL_REGISTER->FemuEcc.FEMU_ECC_BITS.EMU_ECC);
/* Supply the address where ECC is being calculated */
FLASH_CONTROL_REGISTER->FemuAddr.u32Register
= 0x0108;
#if defined(_LITTLE_ENDIAN)
/* Supply the lower 32bit word */
FLASH_CONTROL_REGISTER->FemuDlsw.u32Register
= oFwpWriteDwordAccessor[3];
/* Supply the upper 32bit word */
FLASH_CONTROL_REGISTER->FemuDmsw.u32Register
= oFwpWriteDwordAccessor[2];
#else
/* Supply the upper 32bit word */
FLASH_CONTROL_REGISTER->FemuDlsw.u32Register
= oFwpWriteDwordAccessor[2];
/* Supply the lower 32bit word */
FLASH_CONTROL_REGISTER->FemuDmsw.u32Register
= oFwpWriteDwordAccessor[3];
#endif
/* Place the Wrapper calculated ECC into FWPWRITE_ECC */
oFwpWriteEccByteAccessor[EI8(1)] = FLASH_CONTROL_REGISTER->FemuEcc.FEMU_ECC_BITS.EMU_ECC);
/* Set command to "Program" */
FLASH_CONTROL_REGISTER->FsmCommand.FSM_COMMAND_BITS.FSMCMD = Fapi_ProgramData;
/* Execute the Program command */
FLASH_CONTROL_REGISTER->FsmExecute.FSM_EXECUTE_BITS.FSMEXECUTE = 0x15U;
/* re-lock FSM registers to prevent writing */
FLASH_CONTROL_REGISTER->FsmWrEna.u32Register
= 0x2U;
SPNA148 – May 2013
Advanced F021 Flash API Erase/Program Usage9
Submit Documentation FeedbackCopyright © 2013, Texas Instruments Incorporated
Example Usagewww.ti.com3.3Erasing Operations3.3.1Erasing a Single Sector With Bank EraseThe following code segment will erase a single Flash sector using the Bank erase command.
NOTE:The Bank Erase command is not a suspendable operation.
FLASH_CONTROL_REGISTER->Fbprot.u32Register = 1U;
/* Disable Level 1 Protection */
/* Enable all sectors of current bank for erase and program.
For EEPROM banks with more
than 16 sectors, this must be 0xFFFF */
FLASH_CONTROL_REGISTER->Fbse.u32Register = 0xFFFF;
FLASH_CONTROL_REGISTER->Fbprot.u32Register = 0U;
/* Enable Level 1 Protection */
/*Unlock FSM registers for writing */
FLASH_CONTROL_REGISTER->FsmWrEna.u32Register
= 0x5U;
FLASH_CONTROL_REGISTER-
>FsmSector.u32Register = 0xFFFE0000;
/* Disable all sectors except for sector 0 from bank
operation */
/* Set command to "Clear the Status Register" */
FLASH_CONTROL_REGISTER->FsmCommand.FSM_COMMAND_BITS.FSMCMD = Fapi_ClearStatus;
/* Execute the Clear Status command */
FLASH_CONTROL_REGISTER->FsmExecute.FSM_EXECUTE_BITS.FSMEXECUTE = 0x15U;
/* Write address to FADDR register.
This address must be within the bank to be erased */
FLASH_CONTROL_REGISTER->Faddr.u32Register = 0x0100U;
/* Set command to "Program" */
FLASH_CONTROL_REGISTER->FsmCommand.FSM_COMMAND_BITS.FSMCMD = Fapi_EraseBank;
/* Execute the Program command */
FLASH_CONTROL_REGISTER->FsmExecute.FSM_EXECUTE_BITS.FSMEXECUTE = 0x15U;
/* re-lock FSM registers to prevent writing */
FLASH_CONTROL_REGISTER->FsmWrEna.u32Register
= 0x2U;
10
Advanced F021 Flash API Erase/Program UsageSPNA148 – May 2013
Submit Documentation FeedbackCopyright © 2013, Texas Instruments Incorporated
www.ti.comReferences3.3.2Erasing a Single Sector With Sector EraseThe following code segment will erase a single Flash sector using the Sector erase command.
FLASH_CONTROL_REGISTER->Fbprot.u32Register = 1U;
/* Disable Level 1 Protection */
/* Enable all sectors of current bank for erase and program.
For EEPROM banks with more
than 16 sectors, this must be 0xFFFF */
FLASH_CONTROL_REGISTER->Fbse.u32Register = 0xFFFF;
FLASH_CONTROL_REGISTER->Fbprot.u32Register = 0U;
/* Enable Level 1 Protection */
/*Unlock FSM registers for writing */
FLASH_CONTROL_REGISTER->FsmWrEna.u32Register
= 0x5U;
/* Set command to "Clear the Status Register" */
FLASH_CONTROL_REGISTER->FsmCommand.FSM_COMMAND_BITS.FSMCMD = Fapi_ClearStatus;
/* Execute the Clear Status command */
FLASH_CONTROL_REGISTER->FsmExecute.FSM_EXECUTE_BITS.FSMEXECUTE = 0x15U;
/* Write address to FADDR register.
This address must be within the bank to be erased */
FLASH_CONTROL_REGISTER->Faddr.u32Register = 0x0100U;
/* Set command to "Program" */
FLASH_CONTROL_REGISTER->FsmCommand.FSM_COMMAND_BITS.FSMCMD = Fapi_EraseSector;
/* Execute the Program command */
FLASH_CONTROL_REGISTER->FsmExecute.FSM_EXECUTE_BITS.FSMEXECUTE = 0x15U;
/* re-lock FSM registers to prevent writing */
FLASH_CONTROL_REGISTER->FsmWrEna.u32Register
= 0x2U;
4ReferencesF021 Flash API Reference Guide (
SPNU501)
SPNA148 – May 2013
Advanced F021 Flash API Erase/Program Usage11
Submit Documentation FeedbackCopyright © 2013, Texas Instruments Incorporated
IMPORTANT NOTICETexas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, enhancements, improvements and other
changes to its semiconductor products and services per JESD46, latest issue, and to discontinue any product or service per JESD48, latest
issue. Buyers should obtain the latest relevant information before placing orders and should verify that such information is current and
complete. All semiconductor products (also referred to herein as “components”) are sold subject to TI’s terms and conditions of sale
supplied at the time of order acknowledgment.
TI warrants performance of its components to the specifications applicable at the time of sale, in accordance with the warranty in TI’s terms
and conditions of sale of semiconductor products. Testing and other quality control techniques are used to the extent TI deems necessary
to support this warranty. Except where mandated by applicable law, testing of all parameters of each component is not necessarily
performed.
TI assumes no liability for applications assistance or the design of Buyers’ products. Buyers are responsible for their products and
applications using TI components. To minimize the risks associated with Buyers’ products and applications, Buyers should provide
adequate design and operating safeguards.
TI does not warrant or represent that any license, either express or implied, is granted under any patent right, copyright, mask work right, or
other intellectual property right relating to any combination, machine, or process in which TI components or services are used. Information
published by TI regarding third-party products or services does not constitute a license to use such products or services or a warranty or
endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property of the
third party, or a license from TI under the patents or other intellectual property of TI.
Reproduction of significant portions of TI information in TI data books or data sheets is permissible only if reproduction is without alteration
and is accompanied by all associated warranties, conditions, limitations, and notices. TI is not responsible or liable for such altered
documentation. Information of third parties may be subject to additional restrictions.
Resale of TI components or services with statements different from or beyond the parameters stated by TI for that component or service
voids all express and any implied warranties for the associated TI component or service and is an unfair and deceptive business practice.
TI is not responsible or liable for any such statements.
Buyer acknowledges and agrees that it is solely responsible for compliance with all legal, regulatory and safety-related requirements
concerning its products, and any use of TI components in its applications, notwithstanding any applications-related information or support
that may be provided by TI. Buyer represents and agrees that it has all the necessary expertise to create and implement safeguards which
anticipate dangerous consequences of failures, monitor failures and their consequences, lessen the likelihood of failures that might cause
harm and take appropriate remedial actions. Buyer will fully indemnify TI and its representatives against any damages arising out of the use
of any TI components in safety-critical applications.
In some cases, TI components may be promoted specifically to facilitate safety-related applications. With such components, TI’s goal is to
help enable customers to design and create their own end-product solutions that meet applicable functional safety standards and
requirements. Nonetheless, such components are subject to these terms.
No TI components are authorized for use in FDA Class III (or similar life-critical medical equipment) unless authorized officers of the parties
have executed a special agreement specifically governing such use.
Only those TI components which TI has specifically designated as military grade or “enhanced plastic” are designed and intended for use in
military/aerospace applications or environments. Buyer acknowledges and agrees that any military or aerospace use of TI components
which have
not been so designated is solely at the Buyer's risk, and that Buyer is solely responsible for compliance with all legal and
regulatory requirements in connection with such use.
TI has specifically designated certain components as meeting ISO/TS16949 requirements, mainly for automotive use. In any case of use of
non-designated products, TI will not be responsible for any failure to meet ISO/TS16949.
ProductsApplicationsAudio
www.ti.com/audioAutomotive and Transportation
www.ti.com/automotiveAmplifiers
amplifier.ti.comCommunications and Telecom
www.ti.com/communicationsData Converters
dataconverter.ti.comComputers and Peripherals
www.ti.com/computersDLP® Products
www.dlp.comConsumer Electronics
www.ti.com/consumer-appsDSP
dsp.ti.comEnergy and Lighting
www.ti.com/energyClocks and Timers
www.ti.com/clocksIndustrial
www.ti.com/industrialInterface
interface.ti.comMedical
www.ti.com/medicalLogic
logic.ti.comSecurity
www.ti.com/securityPower Mgmt
power.ti.comSpace, Avionics and Defense
www.ti.com/space-avionics-defenseMicrocontrollers
microcontroller.ti.comVideo and Imaging
www.ti.com/videoRFID
www.ti-rfid.comOMAP Applications Processors
www.ti.com/omapTI E2E Communitye2e.ti.comWireless Connectivity
www.ti.com/wirelessconnectivityMailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2013, Texas Instruments Incorporated
Document Outline
12 - SPNU501Fs
F021 Flash APIVersion 2.01.00Reference GuideLiterature Number: SPNU501F
December 2012 – Revised May 2014
Contents1Introduction.........................................................................................................................
41.1
Reference Material .......................................................................................................
41.2
Function Listing Format .................................................................................................
42F021 Flash API Overview ......................................................................................................
62.1
Introduction................................................................................................................
62.2
API Overview .............................................................................................................
62.3
Using API..................................................................................................................
73API Functions ....................................................................................................................
103.1
Flash State Machine Functions .......................................................................................
103.2
Asynchronous Functions ..............................................................................................
163.3
Program Functions .....................................................................................................
183.4
Read Functions .........................................................................................................
203.5
Informational Functions ................................................................................................
293.6
Utility Functions .........................................................................................................
323.7
User Definable Functions..............................................................................................
334API Macros ........................................................................................................................
344.1
FAPI_CHECK_FSM_READY_BUSY ................................................................................
344.2
FAPI_CLEAR_FSM_DONE_EVENT.................................................................................
344.3
FAPI_GET_FSM_STATUS ............................................................................................
354.4
FAPI_SUSPEND_FSM ................................................................................................
364.5
FAPI_WRITE_EWAIT ..................................................................................................
374.6
FAPI_WRITE_LOCKED_FSM_REGISTER .........................................................................
375Recommended FSM Flows ..................................................................................................
375.1
New Devices From Factory ...........................................................................................
375.2
Recommended Erase Flows ..........................................................................................
385.3
Recommended Program Flow ........................................................................................
40Appendix A Flash State Machine Commands.................................................................................
41A.1
Flash State Machine Commands....................................................................................
41Appendix B Typedefs and Enumerations.......................................................................................
42B.1
Type Definitions .......................................................................................................
42B.2
Enumerations ..........................................................................................................
42Appendix C Flash Validation Procedure ........................................................................................
47Appendix D Parallel Signature Analysis (PSA) algorithm.................................................................
48Appendix E Revision History .......................................................................................................
492
Table of ContentsSPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comList of Figures1
FMSTAT Register ..........................................................................................................
352
Recommended Sector Erase Flow.......................................................................................
383
Recommended Bank Erase Flow ........................................................................................
394
Recommended Program Flow ............................................................................................
40List of Tables1
Summary of Flash State Machine Functions.............................................................................
62
Summary of Asynchronous Command Functions .......................................................................
63
Summary of Program Functions ...........................................................................................
64
Summary of Read Functions ...............................................................................................
75
Summary of Information Functions ........................................................................................
76
Summary of User Defined Functions......................................................................................
77
Summary of Utility Functions...............................................................................................
78
FMSTAT Register Field Descriptions ....................................................................................
359
Flash State Machine Commands ........................................................................................
4110
API Version History ........................................................................................................
4911
Document Revision History ...............................................................................................
50SPNU501F – December 2012 – Revised May 2014
List of Figures3
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
Reference GuideSPNU501F – December 2012 – Revised May 20141IntroductionBackgroundThis reference guide provides a detailed description of Texas Instruments' F021 Flash API functions that
can be used to erase, program and verify F021 Flash on TI devices.
1.1Reference MaterialUse this guide in conjunction with the
F021 Flash Module chapter in the device-specific technical
reference manual and data sheet that is being used. For additional options for programming and erasing
the Flash, see the
Advanced F021 Flash API Erase/Program Usage (SPNA148).
1.2Function Listing FormatThis is the general format of an entry for a function, compiler intrinsic, or macro.
A short description of what function
function_name() does.
SynopsisProvides a prototype for function
function_name().
<return_type> function_name(
<type_1> parameter_1,
<type_2> parameter_2,
<type_n> parameter_n
)
Parametersparameter_1 [in]Pointer to x
parameter_2 [out]Handle for y
parameter_n [in/out]Pointer to z
Parameter passing is categorized as follows:
•
In — Means the function uses one or more values in the parameter that you give it without storing any
changes.
•
Out — Means the function saves one or more of the values in the parameter that you give it. You can
examine the saved values to find out useful information about your application.
•
In/out — Means the function changes one or more of the values in the parameter that you give it and
saves the result. You can examine the saved values to find out useful information about your
application.
DescriptionDescribes the function
function_name(). This section also describes any special characteristics or
restrictions that might apply:
•
Function blocks or might block under certain conditions
•
Function has pre-conditions that might not be obvious
•
Function has restrictions or special behavior
All trademarks are the property of their respective owners.
4
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comIntroductionReturn ValueSpecifies any value or values returned by function
function_name().
See AlsoLists other functions or data types related to function
function_name().
ExampleProvides an example (or a reference to an example) that illustrates the use of function
function_name().
SPNU501F – December 2012 – Revised May 2014
5
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
F021 Flash API Overviewwww.ti.com2F021 Flash API Overview2.1IntroductionThe F021 Flash API is a library of routines that when called with the proper parameters in the proper
sequence, erases, programs, or verifies Flash memory on Texas Instruments microcontrollers using the
F021 (65nm) process. On ARM Cortex devices, these routines must be run in a
privileged mode (a mode
other than user) to allow access to the Flash memory controller registers. The API verifies for the selected
bank, that the appropriate RWAIT or EWAIT value is set for the specified system frequency.
2.2API OverviewTable 1. Summary of Flash State Machine FunctionsAPI FunctionDescriptionFapi_disableAutoEccCalculation()(1)
Disables auto generation of ECC when data is written into an FWPWRITEx
register.
Fapi_disableBanksForOtpWrite()
Disables all banks from programming customer OTP
Fapi_disableFsmDoneEvent()
Disables the generation of an FSM_Done event at the end of a program or erase
operation.
Fapi_enableAutoEccCalculation()(1)
Enables auto generation of ECC when data is written into an FWPWRITEx register.
Fapi_enableBanksForOtpWrite()
Enables banks to allow programming of customer OTP
Fapi_enableEepromBankSectors()
Enables the sectors in EEPROM bank for program and erase operations
Fapi_enableFsmDoneEvent()
Enables the generation of an FSM_Done event at the end of a program or erase
operation.
Fapi_enableMainBankSectors()
Enables the sectors in Main banks for program and erase operations
Fapi_initializeFlashBanks()
Required Bank initialization before any erase, program, or verify API function.
Fapi_isAddressEcc()
Determines if address falls in Flash memory controller ECC ranges
Fapi_remapEccAddress()
Remaps an ECC address to corresponding main address
Fapi_remapMainAddress()
Remaps an Main address to corresponding ECC address
Fapi_setActiveFlashBank()
Sets the active bank for a erase or program command
(1)
This function is only available on devices with the L2FMC Flash Controller.
Table 2. Summary of Asynchronous Command FunctionsAPI FunctionDescriptionFapi_issueAsyncCommand()
Issues a command to FSM for operations that do not require an address
Fapi_issueAsyncCommandWithAddress()
Issues a command to FSM for operations that require an address
Table 3. Summary of Program FunctionsAPI FunctionDescriptionSets up the required registers for programming and issues the command to the
Fapi_issueProgrammingCommand()
FSM
Fapi_issueProgrammingCommandForEccAdd
Remaps an ECC address to the main data space and then call
ress()
Fapi_issueProgrammingCommand()
6
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comF021 Flash API OverviewTable 4. Summary of Read FunctionsAPI FunctionDescriptionFapi_doVerify()
Verifies specified Flash memory range against supplied values
Fapi_doVerifyByByte()
Verifies specified Flash memory range against supplied values by byte
Fapi_doBlankCheck()(1)
Verifies specified Flash memory range against erased state
Fapi_doBlankCheckByByte()(1)
Verifies specified Flash memory range against erased state by byte
Fapi_doMarginRead()
Reads a specified Flash memory range using the specified read-margin mode
Fapi_doMarginReadByByte()
Reads a specified Flash memory range using the specified read-margin mode by
byte
Fapi_doPsaVerify()
Verifies a specified Flash memory range against the supplied PSA value
Fapi_calculatePsa()
Calculates a PSA value for the specified Flash memory range
Fapi_flushPipeline()
Flushes the pipeline buffers in the Flash memory controller
(1)
On devices using L2FMC memory controller, ECC may not be disabled for Banks 0 - 6 and therefore performing a blank check
with the Flash API functions are not supported.
Table 5. Summary of Information FunctionsAPI FunctionDescriptionFapi_getLibraryInfo()
Returns the information specific to the compiled version of the API library
Fapi_getDeviceInfo()
Returns the information specific to the device the API library is being executed on
Fapi_getBankSectors()
Returns the sector information for a bank
Table 6. Summary of User Defined FunctionsAPI FunctionDescriptionFapi_serviceWatchdogTimer()
User modifiable function to service watchdog timer
Table 7. Summary of Utility FunctionsAPI FunctionDescriptionFapi_calculateFletcherChecksum()
Function calculates a Fletcher checksum for the memory range specified
Fapi_calculateEcc()
Calculates the ECC for the supplied address and 64-bit word
Fapi_waitDelay()(1)
Creates a delay
(1)
This function is deprecated and should not be used in new projects
2.3Using APIThis section describes how to use the various API functions and any relevant flows.
2.3.1Initialization FlowFor proper initialization of the device prior to any Flash operations, see the device-specific initialization
document. Additionally,
all API functions require execution in privilege mode.
2.3.1.1Before Using Any Erase, Program or Read Flash API FunctionBefore using any
asynchronous command Table 2 ,
program Table 3 or
read Table 4 functions, the
function
Fapi_initializeFlashBanks() must be called to correctly initialize the Flash Memory controller.
SPNU501F – December 2012 – Revised May 2014
7
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
F021 Flash API Overviewwww.ti.com2.3.1.2Bank SetupBefore performing a Flash erase or program operation for the first time or on a different Bank than is the
current active Bank, the function
Fapi_setActiveFlashBank() must be called. Additionally,
Fapi_enableMainBankSectors() (for banks 0-6) or
Fapi_enableEepromBankSectors() (for bank 7) must be
called before the first sector erase or program operation and always before a bank erase operation.
2.3.1.3On System Frequency ChangeIf the System operating frequency (HCLK) is changed after the initial call to
Fapi_initializeFlashBanks(),
this function along with
Fapi_setActiveFlashBank() must be called again before any
asynchronous
command Table 2 ,
program Table 3 or
read Table 4 function. This will update the Flash Memory
controller to the new system frequency.
2.3.2Flash AddressingFor program and erase operations on Bank 0 to Bank 6, the API and the FMC requires the standard Flash
memory map where Bank 0, Sector 0 begins at address 0. For the read functions on the Flash memory in
Bank 0 to Bank 6, they need either current address mapping (Flash addresses starting at either 0 {Power
On State} or 0x0800_0000 {RAM-Flash swap) or mirrored addresses starting at 0x2000_0000.
2.3.3Building With the APIThe macro
_L2FMC must be defined before the inclusion of the header file F021.h on devices with the
L2FMC Flash controller.
#define _L2FMC
2.3.3.1Object Library FilesAll ARM Cortex Flash API object files are distributed in the ARM standard EABI ELF object format. For the
CortexR4/R5 cores, the library files are built using Thumb2 mode.
2.3.3.2Distribution FilesThe following API files are distributed with the installer:
•
Library Files -
(All library files were built using TI's code generation tools for ARM v5.1.3 with the
following compile options: -mv7R4 --abi=eabi --strict_ansi -g -O3 --symdebug:dwarf_version=3 --
diag_warning=225 --gen_func_subsections=on --enum_type=packed --code_state=16 )–
F021_API_CortexR4_BE.lib – This is the Flash API object file for Cortex R4 Big Endian devices.
–
F021_API_CortexR4_BE_v3D16.lib – This is the Flash API object file for Cortex R4 Big Endian
devices that are using floating point unit.
(In addition to the general build options, this library was
built using : --float_support=VFPv3D16)–
F021_API_CortexR4_BE_L2FMC.lib – This is the Flash API object file for Cortex R4 Big Endian
devices using the L2FMC memory controller.
–
F021_API_CortexR4_LE.lib – This is the Flash API object file for Cortex R4 Little Endian devices.
(In addition to the general build options, this library was built using : -me)–
F021_API_CortexR4_LE_v3D16.lib – This is the Flash API object file for Cortex R4 Little Endian
devices that are using floating point unit.
(In addition to the general build options, this library was
built using : -me --float_support=VFPv3D16)–
F021_API_CortexR4_LE_L2FMC.lib – This is the Flash API object file for Cortex R4 Little Endian
devices using the L2FMC memory controller.
–
F021_API_CortexR4_BE_L2FMC_v3D16.lib – This is the Flash API object file for Cortex R4/R5 Big
Endian devices using the L2FMC memory controller and float point unit.
(In addition to the general
build options, this library was built using : --float_support=VFPv3D16)–
F021_API_CortexR4_LE_L2FMCv3D16.lib – This is the Flash API object file for Cortex R4/R5 Little
Endian devices using the L2FMC memory controller and float point unit.
(In addition to the general
build options, this library was built using : -me --float_support=VFPv3D16)8
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comF021 Flash API Overview•
Source Files
–
Fapi_UserDefinedFunctions.c – This is file that contains the user definable functions.
•
Include Files
–
F021.h – This is the master include file and includes all other include files. This should be the only
include file added to the users's code.
•
The following include files should not be included directly by the user’s code, but are listed here for
user reference:
–
Compatibility.h - A set of macros to be used for backwards compatibility for 1.x.x versions of the
API.
–
Constants.h – Constant definitions used by the API.
–
FapiFunctions.h - Contains all the Fapi function prototypes.
–
Helpers.h – Set of helper defines
–
Registers.h – Definitions common to all register implementations and includes the appropriate
register include file for the selected device type.
–
Registers_FMC_BE.h – Big Endian Flash memory controller registers structure for TMS570/RM4
devices.
–
Registers_FMC_LE.h – Little Endian Flash memory controller registers structure for TMS570/RM4
devices.
–
Types.h – Contains all the enumerations and structures used by the API
–
Below are a set of compiler specific support header files:
•
CGT.ARM.h - Contains a set of definitions used by the ARM compiler
•
CGT.CCS.h - Contains a set of definitions used by the TI CCS compiler
•
CGT.gcc.h - Contains a set of definitions used by the gcc compiler
•
CGT.GHS.h - Contains a set of definitions used by the GreenHills compiler
•
CGT.IAR.h - Contains a set of definitions used by the IAR EWARM compiler
•
Library information files
–
build_information.txt - This file contains function callgraphs, worst case stack usage for each
function, function size in bytes and MD5 and SHA1 checksums for all files delivered in the installer
package.
–
License_Agreement.pdf - This file contains the libraries license agreement.
–
readme.txt - This file contains build specific information.
–
Release_Notes.pdf - This file contains release specific information.
–
spna148.pdf - This is the application note, Advanced F021 Flash API Erase/Program Usage.
–
spnu501e.pdf - This file.
–
spnz210.pdf - This is the library errata document.
2.3.4Executing API From FlashNOTE:The F021 Flash API library cannot be executed from the same bank as the active bank
selected for the API commands to operate on. On single bank devices, the F021 Flash API
must be executed from RAM.
2.3.5Memory Regions Required to be ReadableNOTE:The F021 Flash API library must be able to read from addresses 0x000, 0x100, 0x200,
0x300, and the TI OTP region, 0xF008_0000 - 0xF00B_0000, for the API to operate
correctly.
SPNU501F – December 2012 – Revised May 2014
9
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Functionswww.ti.com3API Functions3.1Flash State Machine Functions3.1.1Fapi_disableAutoEccCalculation()Disables auto generation of ECC on L2FMC devices
SynopsisFapi_StatusType Fapi_disableAutoEccCalculation(void)
ParametersNone
DescriptionNOTE:This function is only available on devices using the L2FMC Flash Memory Controller.
This function disables the auto generation of ECC when data is written to the FWPWRITEx registers on
L2FMC devices. The use of this function is primarily intended for those users writing their own
programming functions based on the application note,
Advanced F021 Flash API Erase/Program Usage
(
SPNA148). The function
Fapi_issueProgrammingCommand() Section 3.2.2 will automatically set this bit
depending on the programming mode used (enabled for Fapi_AutoEccGeneration, disabled for all other
modes) and will stay that way when this function returns.
Return Value•
Fapi_Status_Success (success)
3.1.2Fapi_disableBanksForOtpWrite()Disables ability to program the Customer OTP on all Flash Banks.
SynopsisFapi_StatusType Fapi_disableBanksForOtpWrite(void)
ParametersNone
DescriptionThis function sets
OTPPRODIS field in the
FBAC register to disable the ability to program the Customer
OTP for all banks.
Return Value•
Fapi_Status_Success (success)
10
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI Functions3.1.3Fapi_disableFsmDoneEvent()Disables generation of the FSM_DONE event.
SynopsisFapi_StatusType Fapi_disableFsmDoneEvent(void)
ParametersNone
DescriptionThis function disables the generation of the FSM_DONE event. For more information on the FSM_DONE
event, see the device-specific technical reference manual.
Return Value•
Fapi_Status_Success (success)
3.1.4Fapi_enableAutoEccCalculation()Enables auto generation of ECC on L2FMC devices
SynopsisFapi_StatusType Fapi_enableAutoEccCalculation(void)
ParametersNone
DescriptionNOTE:This function is only available on devices using the L2FMC Flash Memory Controller.
This function enables the auto generation of ECC when data is written to the FWPWRITEx registers on
L2FMC devices. The use of this function is primarily intended for those users writing their own
programming functions based on
Advanced F021 Flash API Erase/Program Usage (
SPNA148). The
function
Fapi_issueProgrammingCommand() Section 3.2.2 will automatically set this bit depending on the
programming mode used (enabled for Fapi_AutoEccGeneration, disabled for all other modes) and will stay
that way when this function returns.
Return Value•
Fapi_Status_Success (success)
SPNU501F – December 2012 – Revised May 2014
11
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Functionswww.ti.com3.1.5Fapi_enableBanksForOtpWrite()Enables ability to program the Customer OTP region for the specified banks
SynopsisFapi_StatusType Fapi_enableBanksForOtpWrite(
uint8_t
u8Banks)
Parametersu8Banks [in]Bit mask indicating each bank to be enabled for OTP programming
DescriptionThis function sets up the
OTPPRODIS field in the
FBAC register to enable the ability to program Customer
OTP for the banks specified in the bitfield mask u8Banks. The bitfield mask has Bank 0 as bit 1 up to
Bank 7 as bit 7.
Return Value•
Fapi_Status_Success (success)
3.1.6Fapi_enableEepromBankSectors()Sets up the sectors available on EEPROM banks for erase and programming
SynopsisFapi_StatusType Fapi_enableEepromBankSectors(
uint32_t
u32SectorsEnables_31_0,
uint32_t
u32SectorsEnables_63_32)
Parametersu32SectorsEnables_31_0 [in]Bit mask indicating which of sectors 0-31 are enabled for erase and
programming.
u32SectorsEnables_63_32 [in]Bit mask indicating which of sectors 32-63 are enabled for erase and
programming.
DescriptionThis function sets up the sectors in the EEPROM banks that are available for erase and programming
operations. This function must be called with the EEPROM bank (Flash Bank 7) as the active bank.
Additionally, the function must be called once before performing program and sector erase operations and
always before a bank erase operation. Each bit refers to a single sector with Sector 0 is bit 0 in
u32SectorEnables_31_0 to Sector 31 is bit 31 in u32SectorEnables_31_0 and Sector 32 is bit 0 in
u32SectorEnables_63_32 to Sector 63 is bit 31 in u32SectorEnables_63_32.
Return Value•
Fapi_Status_Success (success)
12
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI Functions3.1.7Fapi_enableFsmDoneEvent()Enables the generation of the FSM_DONE event
SynopsisFapi_StatusType Fapi_enableBanksForOtpWrite(void)
ParametersNone
DescriptionThis function enables the generation of the FSM_DONE event. This event is generated when the FSM
finishes a program or erase operation. The FSM_DONE event flag resides in the FEDACSTATUS register
at bit 24. For a complete description of the FEDACSTATUS register and FSM_DONE event, see the
F021
Flash Module chapter in the device-specific technical reference manual. This FSM_DONE flag must be
cleared by writing a one to this bit in order for the event signal to stop. There is a helper macro
CLEAR_FSM_DONE_EVENT defined to accomplish this.
Return Value•
Fapi_Status_Success (success)
3.1.8Fapi_enableMainBankSectors()Sets up the sectors available on non-EEPROM banks for erase and programming
SynopsisFapi_StatusType Fapi_enableMainBankSectors(
uint16_t
u16SectorsEnables)
Parametersu16SectorsEnables [in]Bit mask indicating which of sectors 0-15 are enabled for erase and
programming.
DescriptionThis function sets up the sectors in the non-EEPROM banks that are available for erase and programming
operations. This function must be called with the bank intended for the erase or program operation as the
active bank. Additionally, the function must be called once before performing program and sector erase
operations and always before a bank erase operation. Each bit refers to a single sector where Sector 0 is
bit 0 to Sector 15 is bit 15 in u16SectorEnables.
Return Value•
Fapi_Status_Success (success)
SPNU501F – December 2012 – Revised May 2014
13
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Functionswww.ti.com3.1.9Fapi_isAddressEcc()Indicates if an address is in the Flash Memory Controller ECC space
Synopsisboolean_t Fapi_isAddressEcc(
uint32_t
u32Address)
Parametersu32Address [in]Address to determine if it lies in ECC address space
DescriptionThis function returns True if the address in u32Address is in ECC address space or False if it is not.
Return Value•
false (Address is not in ECC address space)
•
true (Address is in ECC address space)
3.1.10Fapi_initializeFlashBanks()Initializes the Flash Banks for API operations
SynopsisFapi_StatusType Fapi_initializeFlashBanks(
uint32_t
u32HclkFrequency)
Parametersu32HclkFrequency [in]System clock frequency in MHz. The value should be rounded up to
the next integer. For example, if the system clock frequency is
133.3MHz, then the u32HclkFrequency value should be 134.
DescriptionThis function is required to initialize the Flash Banks before using any
asynchronous command Table 2 ,
program Table 3 or
read Table 4 functions. This function must also be called if the system frequency is
changed and/or RWAIT/EWAIT values are changed.
NOTE:This function requires that Bank 7 be enabled and powered. Once this function has
completed, Bank 7 may be disabled and powered off.
RWAIT and EWAIT register values must be set before calling this function. There is a helper
macro FAPI_WRITE_EWAIT(_mEwait) is provided to make writing the EWAIT value easier
due to the need for the EEPROM_CONFIG register to be unlocked before you can write the
EWAIT value.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_InvalidHclkValue (failure: System clock does not match specified wait value)
•
Fapi_Error_OtpChecksumMismatch (failure: Calculated TI OTP checksum does not match value in
TI OTP)
14
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI Functions3.1.11Fapi_remapEccAddress()Takes ECC address and remaps it to main address space
Synopsisuint32_t Fapi_remapEccAddress(
uint32_t
u32EccAddress)
Parametersu32EccAddress [in]ECC address to remap
DescriptionThis function returns the main Flash address for the given ECC Flash address passed in u32EccAddress.
Return Value•
32-bit Main Flash Address3.1.12Fapi_remapMainAddress()Takes Flash Main address and remaps it to its corresponding ECC address
Synopsisuint32_t Fapi_remapMainAddress(
uint32_t
u32MainAddress)
Parametersu32MainAddress [in]Main address to remap
DescriptionThis function returns the ECC Flash address for the given Main Flash address passed in
u32MainAddress.
Return Value•
32-bit ECC Flash AddressSPNU501F – December 2012 – Revised May 2014
15
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Functionswww.ti.com3.1.13Fapi_setActiveFlashBank()Sets the active Flash Bank
SynopsisFapi_StatusType Fapi_setActiveFlashBank(
Fapi_FlashBankType
oNewFlashBank)
ParametersoNewFlashBank [in]Bank number to set as active
DescriptionThis function sets the active bank (passed in oNewFlashBank) for any Flash operation issued after calling
this function.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_InvalidBank (failure: Bank specified does not exist on device)
3.2Asynchronous Functions3.2.1Fapi_issueAsyncCommand()Issues a command to the Flash State Machine that only requires a command
SynopsisFapi_StatusType Fapi_issueAsyncCommand(
Fapi_FlashStateCommandsType
oCommand)
ParametersoCommand [in]Command to issue to the FSM
DescriptionThis function issues a command to the Flash State Machine for commands not requiring any additional
information. Typical commands are Clear Status, Program Resume, Erase Resume and Clear_More.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_InvalidCommand (failure: Command specified requires an address to be specified)
16
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI Functions3.2.2Fapi_issueAsyncCommandWithAddress()Issues a command to the Flash State Machine with an address
SynopsisFapi_StatusType Fapi_issueAsyncCommandWithAddress(
Fapi_FlashStateCommandsType
oCommand,
uint32_t *
pu32StartAddress)
ParametersoCommand [in]Command to issue to the FSM
pu32StartAddress [in]Address for needed for Flash State Machine operation
DescriptionThis function issues a command to the Flash State Machine for commands requiring an address to
function correctly. Primary commands used with function are Erase Sector and Erase Bank.
NOTE:Reading a Flash memory location from the bank that an erase command (sector or bank) is
currently being performed will stall the CPU until the erase command finishes and the
FMSTAT register indicates the FSM is not busy.
The Bank Erase command is not a suspendable operation.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_InvalidCommand (failure: Command specified does not require an address to be
specified or is a program command)
SPNU501F – December 2012 – Revised May 2014
17
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Functionswww.ti.com3.3Program Functions3.3.1Fapi_issueProgrammingCommand()Sets up data and issues program command to valid Flash memory addresses
SynopsisFapi_StatusType Fapi_issueProgrammingCommand(
uint32_t
*pu32StartAddress,
uint8_t
*pu8DataBuffer,
uint8_t
u8DataBufferSizeInBytes,
uint8_t
*pu8EccBuffer,
uint8_t
u8EccBufferSizeInBytes,
Fapi_FlashProgrammingCommandType
oMode)
Parameterspu32StartAddress [in]start address in Flash for the data and ECC to be programmed
pu8DataBuffer [in]pointer to the Data buffer address
u8DataBufferSizeInBytes [in]number of bytes in the Data buffer
pu8EccBuffer [in]pointer to the ECC buffer address
u8EccBufferSizeInBytes [in]number of bytes in the ECC buffer
oMode [in]Indicates the programming mode to use:
Fapi_DataOnly
Programs only the data buffer
Fapi_AutoEccGeneration
Programs the data buffer and
auto generates and programs the
ECC.
Fapi_DataAndEcc
Programs both the data and ECC
buffers
Fapi_EccOnly
Programs only the ECC buffer
DescriptionThis function sets up the programming registers of the Flash State Machine based on the supplied
parameters. It offers four different programming modes to the user and handles multiple bank widths
automatically.
Programming modes:Fapi_DataOnly – This mode will only program the data portion in Flash at the address specified. It can
program from 1 byte up to the bank width (8,16,32) bytes based on the bank architecture. The supplied
starting address to program at plus the data buffer length cannot exceed the bank data width. (Ex.
Programming 14 bytes on a 16 byte wide bank starting at address 0x4 is not allowed.)
Fapi_AutoGeneration – This will program the supplied data portion in Flash along with automatically
generated ECC. ECC is calculated on 64-bit aligned addresses up to the data width of the bank. Data not
supplied is treated as 0xFF. For example, on a device with a 144-bit wide bank width, if data is written
only to bytes 0x0-0x7 (or 0x8-0xF), then the ECC will only be calculated for those 64 bits. If the data
supplied crosses a 64-bit boundary, ECC will be calculated for both 64-bit words. For example, on a
device with a 144-bit wide bank width, data is written to bytes 0x4 - 0xB, the 2 bytes of ECC data will be
calculated. The data restrictions for Fapi_DataOnly also exist for this option.
Fapi_DataAndEcc – This will program both the supplied data and ECC in Flash at the address specified.
The data supplied must be aligned on a 64-bit word and the length of data must correlate to the supplied
ECC. (For example, data buffer length is 8 bytes, the ECC buffer must be 1 byte).
Fapi_EccOnly – This mode will only program the ECC portion in Flash at the address specified. It can
program from 1 byte up to the bank ECC width (1, 2, 4) bytes based on the bank architecture. The
supplied starting address to program at plus the ECC buffer length cannot exceed the bank ECC width
(programming 3 bytes on a 2 byte ECC wide bank starting at address 0x0 is not allowed).
18
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI FunctionsNOTE:Reading a Flash memory location from the bank that an program command is currently
being performed will stall the CPU until the program command finishes and the FMSTAT
register indicates the FSM is not busy.
The length of pu8DataBuffer and pu8EccBuffer cannot exceed the bank width of the current
active bank. For bank width information, see the
F021 Flash Module chapter in the device-
specific technical reference manual.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_AsyncIncorrectDataBufferLength (failure: Data buffer size specified exceeds Data bank
width)
•
Fapi_Error_AsyncIncorrectEccBufferLength (failure: ECC buffer size specified exceeds ECC bank
width)
•
Fapi_Error_AsyncDataEccBufferLengthMismatch (failure: Data buffer size either is not 64-bit
aligned or Data length exceeds amount ECC supplied)
3.3.2Fapi_issueProgrammingCommandForEccAddress()SynopsisFapi_StatusType Fapi_issueProgrammingCommandForEccAddress(
uint32_t
*pu32StartAddress,
uint8_t
*pu8EccBuffer,
uint8_t
u8EccBufferSizeInBytes)
Parameterspu32StartAddress [in]ECC start address in Flash for the ECC to be programmed
pu8EccBuffer [in]pointer to the ECC buffer address
u8EccBufferSizeInBytes [in]number of bytes in the ECC buffer
DescriptionThis function will remap an address in the ECC memory space to the corresponding data address space
and then call Fapi_issueProgrammingCommand() to program the supplied ECC data. The same
limitations for Fapi_issueProgrammingCommand() using Fapi_EccOnly mode applies to this function.
NOTE:Reading a Flash memory location from the bank that a program command is currently being
performed will stall the CPU until the program command finishes and the FMSTAT register
indicates the FSM is not busy.
The length of pu8EccBuffer cannot exceed the bank width of the current active bank. For
bank width information, see the
F021 Flash Module chapter in the device-specific technical
reference manual.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_AsyncIncorrectEccBufferLength (failure: Data buffer size specified exceeds ECC bank
width)
SPNU501F – December 2012 – Revised May 2014
19
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Functionswww.ti.com3.4Read FunctionsThe read functions do not combine main and ECC ranges. Because this, if you need a read operation
performed on the data and corresponding ECC, you must call the function for both. For example, if you
have erased Bank 0, Sector 0, you would need to perform a blank check on Sector 0 main address range
and ECC address range.
3.4.1Fapi_doBlankCheck()Verifies region specified is erased value
SynopsisFapi_StatusType Fapi_doBlankCheck(
uint32_t
*pu32StartAddress,
uint32_t
u32Length,
Fapi_FlashStatusWordType
*poFlashStatusWord)
Parameterspu32StartAddress [in]start address for region to blank check
u32Length [in]length of region in 32-bit words to blank check
poFlashStatusWord [out]returns the status of the operation if result is not
Fapi_Status_Success
->au32StatusWord[0]
address of first non-blank location
->au32StatusWord[1]
data read at first non-blank location
->au32StatusWord[2]
value of compare data (always 0xFFFFFFFF)
->au32StatusWord[3]
indicates read mode that failed blank check
DescriptionThis function checks the device for blank (erase state) starting at the specified address for the length of
32-bit words specified. If a non-blank location is found, these results will be returned in the
poFlashStatusWord parameter. This will use read margin 1 mode for this check. As the erase state of the
Flash is not a valid ECC condition, on Banks 0 - 6 ECC correction at a minimum must be disabled. On
Bank 7, ECC can either be temporarily disabled by writing 0101 to the EE_EDACEN bits or setting the
EE_ALL1_OK bit EE_CTRL1 register.
This function assumes the value passed in
pu32StartAddress is a 32bit aligned address.
NOTE:On devices using L2FMC memory controller, ECC may not be disabled for Banks 0 - 6 and
therefore performing a blank check with the Flash API functions are not supported.
RestrictionsThe region being blank checked cannot cross bank address boundary.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_Fail (failure: region specified is not blank)
20
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI Functions3.4.2Fapi_doBlankCheckByByte()Verifies region specified is erased value by byte
SynopsisFapi_StatusType Fapi_doBlankCheckByByte(
uint8_t
*pu8StartAddress,
uint32_t
u32Length,
Fapi_FlashStatusWordType
*poFlashStatusWord)
Parameterspu8StartAddress [in]start address for region to blank check
u32Length [in]length of region in 32-bit words to blank check
poFlashStatusWord [out]returns the status of the operation if result is not
Fapi_Status_Success
->au32StatusWord[0]
address of first non-blank location
->au32StatusWord[1]
data read at first non-blank location
->au32StatusWord[2]
value of compare data (always 0xFF)
->au32StatusWord[3]
indicates read mode that failed blank check
DescriptionThis function checks the device for blank (erase state) starting at the specified address for the length of 8-
bit words specified. If a non-blank location is found, these results will be returned in the
poFlashStatusWord parameter. This will use read margin 1 mode for this check. As the erase state of the
Flash is not a valid ECC condition, on Banks 0 - 6 ECC correction at a minimum must be disabled. On
Bank 7, ECC can either be temporarily disabled by writing 0101 to the EE_EDACEN bits or setting the
EE_ALL1_OK bit EE_CTRL1 register.
NOTE:On devices using L2FMC memory controller, ECC may not be disabled for Banks 0 - 6 and
therefore performing a blank check with the Flash API functions are not supported.
RestrictionsThe region being blank checked cannot cross bank address boundary.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_Fail (failure: region specified is not blank)
SPNU501F – December 2012 – Revised May 2014
21
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Functionswww.ti.com3.4.3Fapi_doVerify()Verifies region specified against supplied data
SynopsisFapi_StatusType Fapi_doVerify(
uint32_t
*pu32StartAddress,
uint32_t
u32Length,
uint32_t
*pu32CheckValueBuffer,
Fapi_FlashStatusWordType
*poFlashStatusWord)
Parameterspu32StartAddress [in]start address for region to verify
u32Length [in]length of region in 32-bit words to verify
pu32CheckValueBufferaddress of buffer to verify region against
[in]poFlashStatusWord [out]returns the status of the operation if result is not
Fapi_Status_Success
->au32StatusWord[0]
address of first verify failure location
->au32StatusWord[1]
data read at first verify failure location
->au32StatusWord[2]
value of compare data
->au32StatusWord[3]
indicates read mode that failed verify
DescriptionThis function verifies the device against the supplied data starting at the specified address for the length of
32-bit words specified. If a location fails to compare, these results will be returned in the
poFlashStatusWord parameter. This will use normal read, read margin 0 and read margin 1 modes for
verifying the data.
This function assumes the value passed in
pu32StartAddress is a 32bit aligned address.
RestrictionsThe region being verified cannot cross bank address boundary.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_Fail (failure: region specified does not match supplied data)
22
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI Functions3.4.4Fapi_doVerifyByByte()Verifies region specified against supplied data by byte
SynopsisFapi_StatusType Fapi_doVerifyByByte(
uint8_t
*pu8StartAddress,
uint32_t
u32Length,
uint8_t
*pu8CheckValueBuffer,
Fapi_FlashStatusWordType
*poFlashStatusWord)
Parameterspu8StartAddress [in]start address for region to verify by byte
u32Length [in]length of region in 8-bit words to verify
pu8CheckValueBufferaddress of buffer to verify region against by byte
[in]poFlashStatusWord [out]returns the status of the operation if result is not
Fapi_Status_Success
->au32StatusWord[0]
address of first verify failure location
->au32StatusWord[1]
data read at first verify failure location
->au32StatusWord[2]
value of compare data
->au32StatusWord[3]
indicates read mode that failed verify
DescriptionThis function verifies the device against the supplied data by the byte starting at the specified address for
the length of 8-bit words specified. If a location fails to compare, these results will be returned in the
poFlashStatusWord parameter. This will use normal read, read margin 0 and read margin 1 modes
checking for verifying the data.
RestrictionsThe region being verified cannot cross bank address boundary.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_Fail (failure: region specified does not match supplied data)
SPNU501F – December 2012 – Revised May 2014
23
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Functionswww.ti.com3.4.5Fapi_doPsaVerify()Verifies region specified against specified PSA value
SynopsisFapi_StatusType Fapi_doPsaVerify(
uint32_t
*pu32StartAddress,
uint32_t
u32Length,
uint32_t
u32PsaValue,
Fapi_FlashStatusWordType
*poFlashStatusWord)
Parameterspu32StartAddress [in]start address for region to verify PSA value
u32Length [in]length of region in 32-bit words to verify PSA value
u32PsaValue [in]PSA value to compare region against
poFlashStatusWord [out]returns the status of the operation if result is not
Fapi_Status_Success
->au32StatusWord[0]
Actual PSA for read-margin 0
->au32StatusWord[1]
Actual PSA for read-margin 1
->au32StatusWord[2]
Actual PSA for normal read
DescriptionThis function verifies the device against the supplied PSA value starting at the specified address for the
length of 32-bit words specified. The calculated PSA values for all 3 margin modes are returned in the
poFlashStatusWord parameter.
This function assumes the value passed in
pu32StartAddress is a 32bit aligned address.
RestrictionsThe region being verified checked cannot cross bank address boundary.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_Fail (failure: region specified does not match supplied data)
24
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI Functions3.4.6Fapi_calculatePsa()Calculates the PSA for a specified region
Synopsisuint32_t Fapi_calculatePsa(
uint32_t
*pu32StartAddress,
uint32_t
u32Length,
uint32_t
u32PsaSeed,
Fapi_FlashReadMarginModeType
oReadMode)
Parameterspu32StartAddress [in]start address for region to calculate PSA value
u32Length [in]length of region in 32-bit words to calculate PSA value
u32PsaSeed [in]seed value for PSA calculation
oReadMode [in]indicates which margin mode (normal, RM0, RM1) to use
DescriptionThis function calculates the PSA value for the region specified starting at pu32StartAddress for u32Length
32-bit words using u32PsaSeed value in the margin mode specified.
This function assumes the value passed in
pu32StartAddress is a 32bit aligned address.
RestrictionsThe region that the PSA is being calculated must be 32-bit aligned.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_InvalidReadMode (failure: read mode specified is not valid)
SPNU501F – December 2012 – Revised May 2014
25
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Functionswww.ti.com3.4.7Fapi_doMarginRead()Reads a region of Flash Memory using specified margin mode
SynopsisFapi_StatusType Fapi_doMarginRead(
uint32_t
*pu32StartAddress,
uint32_t
*pu32ReadBuffer,
uint32_t
u32Length,
Fapi_FlashReadMarginModeType
oReadMode)
Parameterspu32StartAddress [in]start address for region to read
pu32ReadBuffer [out]address of buffer to return read data
u32Length [in]length of region in 32-bit words to read
oReadMode [in]indicates which margin mode (normal, RM0, RM1) to use
DescriptionThis function reads the region specified starting at pu32StartAddress for u32Length 32-bit words using
pu32ReadBuffer to store the read values.
This function assumes the value passed in
pu32StartAddress is a 32bit aligned address.
NOTE:The region that is being read cannot cross bank address boundary.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_InvalidReadMode (failure: read mode specified is not valid)
•
Fapi_Error_NullPointer (failure: pu32ReadBuffer is a NULL pointer)
26
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI Functions3.4.8Fapi_doMarginReadByByte()Reads a region of Flash Memory using specified margin mode by byte
SynopsisFapi_StatusType Fapi_doMarginReadByByte(
uint8_t
*pu8StartAddress,
uint8_t
*pu8ReadBuffer,
uint32_t
u32Length,
Fapi_FlashReadMarginModeType
oReadMode)
Parameterspu8StartAddress [in]start address for region to read by byte
pu8ReadBuffer [out]address of buffer to return read data by byte u32
Length [in]length of region in 32-bit words to read
oReadMode [in]indicates which margin mode (normal, RM0, RM1) to use
DescriptionThis function reads the region specified starting at pu8StartAddress for u32Length 8-bit words using
pu8ReadBuffer to store the read values.
RestrictionsThe region that is being read cannot cross bank address boundary.
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_InvalidReadMode (failure: read mode specified is not valid)
•
Fapi_Error_NullPointer (failure: pu8ReadBuffer is a NULL pointer)
SPNU501F – December 2012 – Revised May 2014
27
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Functionswww.ti.com3.4.9Fapi_flushPipeline()Flushes the FMC pipeline buffers
Synopsisvoid Fapi_flushPipeline(void)
ParametersNone
DescriptionThis function flushes the FMC pipeline buffers.
NOTE:The pipeline must be flushed before the first non-API Flash read after an operation that
modifies the Flash contents (Erasing and Programming).
This function makes the assumption that is can read from Flash Addresses 0, 0x100, 0x200,
0x300.
If the Flash and RAM memory regions are swapped, you will need to do 2 dummy reads 128
bytes apart from the remapped Flash memory addresses after an operation that modifies the
Flash contents (Erasing and Programming) before performing any API read functions.
Return ValueNone
28
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI Functions3.5Informational Functions3.5.1Fapi_getLibraryInfo()Returns information about this compile of the Flash API
SynopsisFapi_LibraryInfoType Fapi_getLibraryInfo(void)
ParametersNoneDescriptionThis function returns information specific to the compile of the Flash API library. The information is
returned in a struct Fapi_LibraryInfoType. The members are as follows:
•
u8ApiMajorVersion – Major version number of this compile of the API
•
u8ApiMinorVersion – Minor version number of this compile of the API
•
u8ApiRevision – Revision version number of this compile of the API
•
oApiProductionStatus – Production status of this compile
(Alpha_Internal, Alpha, Beta_Internal, Beta,
Production)•
u32ApiBuildNumber – Build number of this compile. Used to differentiate between different alpha and
beta builds
•
u8ApiTechnologyType – Indicates the Flash technology supported by the API. F021 is tech type of
0x04
•
u8ApiTechnologyRevision – Indicates the revision of the Technology supported by the API
•
u8ApiEndianness – Indicates if this compile of the API is for Big Endian or Little Endian memory
•
u32ApiCompilerVersion – Version number of the Code Composer Studio code generation tools used to
compile the API
Return Value•
Fapi_LibraryInfoType (gives the information retrieved about this compile of the API)
SPNU501F – December 2012 – Revised May 2014
29
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Functionswww.ti.com3.5.2Fapi_getDeviceInfo()Returns information about specific to device code is being executed on
SynopsisFapi_DeviceInfoType Fapi_getDeviceInfo(void)
ParametersNoneDescriptionThis function returns information about the specific device the Flash API library is being executed on. The
information is returned in a struct Fapi_DeviceInfoType. The members are as follows:
•
u16NumberOfBanks – Number of banks on the device
•
u16DevicePackage – Device package pin count
•
u16DeviceMemorySize – Device memory size
•
u32AsicId – Device ASIC id
•
u32LotNumber – Device lot number
•
u16FlowCheck – Device Flow check
•
u16WaferNumber – Device wafer number
•
u16WaferXCoordinate – Device wafer X coordinate
•
u16WaferYCoordinate – Device wafer Y coordinate
Return Value•
Fapi_DeviceInfoType (gives the information retrieved about this compile of the API)
30
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI Functions3.5.3Fapi_getBankSectors()Returns the sector information for the requested bank
SynopsisFapi_StatusType Fapi_getBankSectors(
Fapi_FlashBankType
oBank,
Fapi_FlashBankSectorsType
*poFlashBankSectors)
ParametersoBank [in]Bank to get information on
poFlashBankSectors [out]Returned structure with the bank information
DescriptionThis function returns information about the bank starting address, number of sectors, sector sizes in
kilobytes, and bank technology type. The information is returned in a struct Fapi_FlashBankSectorsType.
The members are as follows:
•
oFlashBankTech – Indicates if bank is an FLEP, FLEE or FLES bank type
•
u32NumberOfSectors – Indicates the number of sectors in the bank
•
u32BankStartAddress – Starting address of the bank
•
au16SectorSizes[] – An array of sectors sizes for each sector in the bank (
As all sectors on FLEE
banks are the same size, only au16SectorSizes[0] is returned with a sector size)
Return Value•
Fapi_Status_Success (success)
•
Fapi_Error_FeatureNotAvailable (failure: Not all devices have this support in the Flash Memory
Controller)
•
Fapi_Error_InvalidBank (failure: Bank does not exist on this device)
•
Fapi_Error_NullPointer (failure: poFlashBankSectors is a NULL pointer)
SPNU501F – December 2012 – Revised May 2014
31
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Functionswww.ti.com3.6Utility Functions3.6.1Fapi_calculateFletcherChecksum()Calculates the Fletcher checksum from the given address and length
Synopsisuint32_t Fapi_calculateFletcherChecksum(
uint16_t
*pu16Data,
uint16_t
u16Length)
Parameterspu16Data [in]Address to start calculating the checksum from
u16Length [in]Number of 16-bit words to use in calculation
DescriptionThis function generates a 32-bit Fletcher checksum starting at the supplied address for the number of 16-
bit words specified.
This function assumes the value passed in
pu16Data is a 16bit aligned address.
Return Value•
• 32-bit Fletcher Checksum value
3.6.2Fapi_calculateEcc()Calculates the ECC for a 64-bit value
Synopsisuint8_t Fapi_calculateEcc(
uint32_t
u32Address,
uint64
u64Data)
Parametersu32Address [in]Address of the 64-bit value to calculate the ECC
u64Data [in]64-bit value to calculate ECC on
DescriptionThis function will calculate the ECC for a 64-bit aligned word including address if device supports address
in ECC calculation.
This function assumes the value passed in
u32Address is a 64bit aligned address.
NOTE:As of version 1.51.0 of the API, this function expects the value in u64Data to be in the
natural Endianness of the system the function is being called on.
Return Value•
8-bit calculated ECC
32
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI Functions3.6.3Fapi_waitDelay() -- DeprecatedGenerates a delay roughly proportional to the value passed. The delay is created with a simple software
loop. The time is not adjusted to account for operating frequency, CPU type or memory access time. This
function will not be supported in future versions of this API.
Synopsisuint8_t Fapi_waitDelay(
uint32_t
u32WaitDelay)
Parametersu32WaitDelay [in]Number of arbitrary units to delay
DescriptionThis function will generate a wait for a time rougnly proportional to the value of u32WaitDelay.
Return Value•
Fapi_Status_Success (success)
3.7User Definable FunctionsThese callback functions are distributed in the file Fapi_UserDefinedFunctions.c and used by the
read
Table 4 functions. These are the base functions called by the API and can be modified to meet the user’s
need for these operations. This file must be compiled with the user’s code.
3.7.1Fapi_serviceWatchdogTimer()Services the watchdog timer
SynopsisFapi_StatusType Fapi_serviceWatchdogTimer(void)
ParametersNoneDescriptionThis function allows the user to service their watchdog timer in the
read Table 4 functions. It is called
when the address being read crosses the 256 byte aligned address boundaries.
Return Value•
Fapi_Status_Success (success)
Sample Implementation#include “F021.h”
Fapi_StatusType Fapi_serviceWatchdogTimer(void)
{
/* User to add their own watchdog servicing code here */
return(Fapi_Status_Success);
}
SPNU501F – December 2012 – Revised May 2014
33
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Macroswww.ti.com4API MacrosThe API includes a set of helper macros that may be used by the developer.
4.1FAPI_CHECK_FSM_READY_BUSYReturns state of FSM.
Synopsis#define FAPI_CHECK_FSM_READY_BUSY (FLASH_CONTROL_REGISTER-
>FmStat.FMSTAT_BITS.BUSY ? Fapi_Status_FsmBusy : Fapi_Status_FsmReady)
ParametersNone
DescriptionThis macro returns the state of the FSM.
Return Value•
Fapi_Status_FsmReady (FSM is ready to accept a new command)
•
Fapi_Status_FsmBusy (FSM is busy and may only accept a suspend command if operation is
program or erase sector)
4.2FAPI_CLEAR_FSM_DONE_EVENTHelper macro to clear FSM_DONE event
Synopsis#define FAPI_CLEAR_FSM_DONE_EVENT (FLASH_CONTROL_REGISTER-
>FedAcStatus.FEDACSTATUS_BITS.FSM_DONE = 1U)
ParametersNone
DescriptionThis macro writes a 1 to the FSM_DONE bit in the FEDACSTATUS register to clear the FSM_DONE
event.
Return ValueNone
34
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI Macros4.3FAPI_GET_FSM_STATUSReturns the value of the FMSTAT register
Synopsis#define GET_FSM_STATUS (FLASH_CONTROL_REGISTER->FmStat.u32Register)
ParametersNone
DescriptionThis macro is used to get the value of the FMSTAT register.
FMSTAT Register ValueFigure 1. FMSTAT Register31
24
Reserved
23
16
Reserved
15
14
13
12
11
10
9
8
Reserved
ILA
Reserved
PGV
Reserved
EV
Reserved
BUSY
7
6
5
4
3
2
1
0
ERS
PGM
INV-DAT
CSTAT
VOLTSTAT
ESUSP
PSUSP
SLOCK
Table 8. FMSTAT Register Field DescriptionsBitFieldDescription15
Reserved
Read returns 0. Writes have no effect.
Illegal Address
14
ILA
When set, indicates that an illegal address is detected. Three conditions can set illegal address
flags.
• Writing to a hole (un-implemented logical address space) within a Flash bank.
• Writing to an address location to an un-implemented Flash space.
• Input address for write is decoded to select a different bank from the bank ID register.
• The address range does not match the type of FSM command. For example, the erase_sector
and erase_OTP commands must match the address regions.
• TI-OTP address selected but CMD_EN in FSM_ST_MACHINE is not set.
13
Reserved
Read returns 0. Writes have no effect.
Program verify When set, indicates that a word is not successfully programmed after the maximum
12
PGV
allowed number of program pulses are given for program operation.
11
Reserved
Read returns 0. Writes have no effect.
Erase verify When set, indicates that a sector is not successfully erased after the maximum
10
EV
allowed number of erase pulses are given for erase operation. During Erase verify command, this
flag is set immediately if a bit is found to be 0.
9
Reserved
Read returns 0. Writes have no effect.
8
BUSY
When set, this bit indicates that a program, erase, or suspend operation is being processed.
Erase Active. When set, this bit indicates that the Flash module is actively performing an erase
7
ERS
operation. This bit is set when erasing starts and is cleared when erasing is complete. It is also
cleared when the erase is suspended and set when the erase resumes.
Program Active. When set, this bit indicates that the Flash module is currently performing a
program operation. This bit is set when programming starts and is cleared when programming is
6
PGM
complete. It is also cleared when programming is suspended and set when programming is
resumes.
SPNU501F – December 2012 – Revised May 2014
35
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
API Macroswww.ti.comTable 8. FMSTAT Register Field Descriptions (continued)BitFieldDescriptionInvalid Data. When set, this bit indicates that the user attempted to program a “1” where a “0” was
5
INVDAT
already present. This bit is cleared by the Clear Status command.
Command Status. Once the FSM starts any failure will set this bit. When set, this bit informs the
host that the program, erase, or validate sector command failed and the command was stopped.
4
CSTAT
This bit is cleared by the Clear Status command. For some errors, this will be the only indication of
an FSM error because the cause does not fall within the other error bit types.
Core Voltage Status. When set, this bit indicates that the core voltage generator of the pump power
3
VOLTSTAT
supply dipped below the lower limit allowable during a program or erase operation. This bit is
cleared by the Clear Status command. Version 3.0.9, 3.1.0 Preliminary Flash Registers
Erase Suspend. When set, this bit indicates that the Flash module has received and processed an
2
ESUSP
erase suspend operation. This bit remains set until the erase resume command has been issued or
until the Clear_More command is run.
Program Suspend. When set, this bit indicates that the Flash module has received and processed
1
PSUSP
a program suspend operation. This bit remains set until the program resume command has been
issued or until the Clear_More command is run.
Sector Lock Status. When set, this bit indicates that the operation was halted because the target
0
SLOCK
sector was locked for erasing and the programming either by the sector protect bit or by OTP write
protection disable bits. This bit is cleared by the Clear Status command.
No SLOCK FSM error will occur if all sectors in a bank erase operation are set to 1. All the sectors
will be checked but no LOCK will be set if no operation occurs due to the SECT_ERASED bits
being set to all ones. A SLOCK error will occur if attempting to do a sector erase with either BSE is
cleared or SECT_ERASED is set. For FLEE Flash banks over 16 sectors, the BSE register must
be set to all ones for a bank or sector erase.
4.4FAPI_SUSPEND_FSMIssues FSM suspend command
Synopsis#define FAPI_SUSPEND_FSM
(FAPI_WRITE_LOCKED_FSM_REGISTER(FLASH_CONTROL_REGISTER-
>FsmExecute.FSM_EXECUTE_BITS.SUSPEND_NOW, 0x5U))
ParametersNone
DescriptionThis macro will issue a FSM suspend command. Only program and erase sector operations are valid
suspendable operations.
Return ValueNone
36
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAPI Macros4.5FAPI_WRITE_EWAITHelper macro to write EWAIT value
Synopsis#define FAPI_WRITE_EWAIT(_mEwait) (FAPI_WRITE_LOCKED_FSM_REGISTER(FLASH_CONTROL_REGISTER-
>EepromConfig.EEPROM_CONFIG_BITS.EWAIT,_mEwait))
Parameters_mEwait [in]EWAIT value to be written
DescriptionThis macro writes _mEwait to the EWAIT bits in the EEPROM_CONFIG register.
Return ValueNone
4.6FAPI_WRITE_LOCKED_FSM_REGISTERAllow easy writing to Flash Memory Controller registers that need to be unlocked first.
Synopsis#define FAPI_WRITE_LOCKED_FSM_REGISTER(mRegister,mValue)
\
do {
\
Fapi_GlobalInit.m_poFlashControlRegisters->FsmWrEna.FSM_WR_ENA_BITS.WR_ENA
= 0x5U; \
mRegister = mValue;
\
Fapi_GlobalInit.m_poFlashControlRegisters->FsmWrEna.FSM_WR_ENA_BITS.WR_ENA
= 0x2U; \
}while(0)
ParametersmRegister [in]Address or bitfield of the locked register to be written to
mValue [in]Value to be written to the locked register
DescriptionThis function sets up the sectors in the non EEPROM banks that are available for erase and programming
operations.
Return ValueNone5Recommended FSM Flows5.1New Devices From FactoryDevices are shipped erased from the Factory. It is recommended, but not required to do a blank check on
devices received to verify that they are erased.
SPNU501F – December 2012 – Revised May 2014
37
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
Recommended FSM Flowswww.ti.com5.2Recommended Erase FlowsFigure 2 and
Figure 3 describe the flow for erasing a sector(s) or bank(s) on a device. For further
information, see
Section 3.2.2.
Start
Call
Fapi_issueAsyncCommandWithAddress() Using
Fapi_EraseSector command
Properly Initialized Device
Call
Fapi_initializeFlashBanks()No
Execute other CHECK_FSM_READY_BUSY code as !=
Fapi_Status_FsmBusyneededCall
Fapi_setActiveFlashBank() for current bank
Yes
Call either
Fapi_enableMainBankSectors() or
Fapi_enableEepromBankSectors() No
appropriate for current bank
GET_FSM_STATUS DUT fails Program
== 0
Yes
Yes
CHECK_FSM_READY_BUSY ==
Fapi_Status_FsmReadyNo
Another Sector to Erase?
Done
No
Yes
No
Is Sector in a different
bank?
Yes
Figure 2. Recommended Sector Erase Flow38
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comRecommended FSM FlowsStart
Call
Fapi_issueAsyncCommandWithAddress() Using
Fapi_EraseBank command
Properly Initialized Device
Call
Fapi_initializeFlashBanks()No
Execute other CHECK_FSM_READY_BUSY code as !=
Fapi_Status_FsmBusyneededCall
Fapi_setActiveFlashBank() for current bank
Yes
Call either
Fapi_enableMainBankSectors() or
Fapi_enableEepromBankSectors() No
appropriate for current bank
GET_FSM_STATUS DUT fails Program
== 0
Yes
Yes
CHECK_FSM_READY_BUSY ==
Fapi_Status_FsmReadyYes
Another Bank to Erase?
No
No
Done
Figure 3. Recommended Bank Erase FlowSPNU501F – December 2012 – Revised May 2014
39
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
Recommended FSM Flowswww.ti.com5.3Recommended Program FlowFigure 4 describes the flow for programming a device. This flow assumes the user has already erased all
affected sectors or banks following the Recommended Erase Flow (see
Section 5.2). For further
information, see
Section 3.3.1.
Start
Call
Fapi_issueProgrammingCommand() Supplying address, data and mode
Properly Initialized Device
No
Call
Execute other CHECK_FSM_READY_BUSY Fapi_initializeFlashBanks()code as !=
Fapi_Status_FsmBusyneededCall
Yes
Fapi_setActiveFlashBank() for current bank
No
Call either
GET_FSM_STATUS DUT fails Program
Fapi_enableMainBankSectors() or
== 0
Fapi_enableEepromBankSectors() appropriate for current bank
Yes
Yes
CHECK_FSM_READY_BUSY No
==
Fapi_Status_FsmReadyMore data to program?
Done
No
Yes
Is data in same bank?
No
Figure 4. Recommended Program Flow40
SPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAppendix A Flash State Machine CommandsA.1Flash State Machine CommandsTable 9. Flash State Machine CommandsCommandDescriptionEnumeration TypeAPI Call(s)Program
Used to program data to
Fapi_ProgramData
Fapi_issueProgrammingCommandForEccAddress()Data
any valid Flash address
Used to erase a Flash
Erase Sector sector located by the
Fapi_EraseSector
specified address
Fapi_issueAsyncCommandWithAddress()Used to erase a Flash bank
Erase Bank
located by the specified
Fapi_EraseBank
address
Clear Status
Clears the status register
Fapi_ClearStatus
Fapi_issueAsyncCommand()Program
Resumes a suspended
Fapi_ProgramResume
Fapi_issueAsyncCommand()Resume
programming operation
Erase
Resumes a suspended
Fapi_EraseResume
Fapi_issueAsyncCommand()Resume
erase operation
Clear More
Clears the status register
Fapi_ClearMore
Fapi_issueAsyncCommand()SPNU501F – December 2012 – Revised May 2014
Flash State Machine Commands41
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAppendix B Typedefs and EnumerationsB.1Type Definitionstypedef unsigned char boolean_t;
B.2EnumerationsB.2.1Fapi_CpuSelectorTypeThis is used to indicate which CPU is being used.
typedef enum
{
Fapi_MasterCpu,
Fapi_SlaveCpu0
} ATTRIBUTE_PACKED Fapi_CpuSelectorType;
B.2.2Fapi_CpuTypeThis is used to indicate what type of Cpu is being used.
typedef enum
{
ARM7 = 0U,
/* ARM7 core, Legacy placeholder */
M3
= 1U,
/* ARM Cortex M3 core */
R4
= 2U,
/* ARM Cortex R4 core without ECC logic */
R4F
= 3U,
/* ARM Cortex R4, R4F, and R5 cores with ECC logic*/
C28
= 4U,
/* TI C28x core */
Undefined1 = 5U,
/* To Be Determined.
Future core placeholder */
Undefined2 = 6U,
/* To Be Determined.
Future core placeholder */
Undefined3 = 7U
/* To Be Determined.
Future core placeholder */
}
ATTRIBUTE_PACKED Fapi_CpuType;
B.2.3Fapi_FamilyTypeThis is used to indicate what type of Family is being used.
typedef enum
{
Family_FMC
= 0x00,
Family_L2FMC
= 0x10,
Family_Sonata
= 0x20,
Family_Stellaris = 0x30,
Family_Future
= 0x40
} ATTRIBUTE_PACKED Fapi_FamilyType;
42
Typedefs and EnumerationsSPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comEnumerationsB.2.4Fapi_AddressMemoryTypeThis is used to indicate what type of Address is being used.
typedef enum
{
Fapi_Flash,
Fapi_FlashEcc,
Fapi_Otp,
Fapi_OtpEcc,
Fapi_Undefined
}
ATTRIBUTE_PACKED Fapi_AddressMemoryType;
B.2.5Fapi_FlashProgrammingCommandsTypeThis contains all the possible modes used in the Fapi_IssueAsyncProgrammingCommand().
typedef enum
{
Fapi_AutoEccGeneration, /* This is the default mode for the command and will auto generate
the ecc for the provided data buffer */
Fapi_DataOnly,
/* Command will only process the data buffer */
Fapi_EccOnly,
/* Command will only process the ecc buffer */
Fapi_DataAndEcc
/* Command will process data and ecc buffers */
}
ATTRIBUTE_PACKED Fapi_FlashProgrammingCommandsType;
B.2.6Fapi_FlashBankTypeThis is used to indicate which Flash bank is being used.
typedef enum
{
Fapi_FlashBank0=0,
Fapi_FlashBank1=1,
Fapi_FlashBank2=2,
Fapi_FlashBank3=3,
Fapi_FlashBank4=4,
Fapi_FlashBank5=5,
Fapi_FlashBank6=6,
Fapi_FlashBank7=7
}
ATTRIBUTE_PACKED Fapi_FlashBankType;
SPNU501F – December 2012 – Revised May 2014
Typedefs and Enumerations43
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
Enumerationswww.ti.comB.2.7Fapi_FlashBankTechTypeThis is used to indicate what F021 Bank Technology the bank is.
typedef enum
{
Fapi_FLEP=0,
Fapi_FLEE=1,
Fapi_FLES=2,
Fapi_FLHV=3
}
ATTRIBUTE_PACKED Fapi_FlashBankTechType;
B.2.8Fapi_FlashSectorTypeThis is used to indicate which Flash sector is being used.
typedef enum
{
Fapi_FlashSector0,
Fapi_FlashSector1,
Fapi_FlashSector2,
Fapi_FlashSector3,
Fapi_FlashSector4,
Fapi_FlashSector5,
Fapi_FlashSector6,
Fapi_FlashSector7,
Fapi_FlashSector8,
Fapi_FlashSector9,
Fapi_FlashSector10,
Fapi_FlashSector11,
Fapi_FlashSector12,
Fapi_FlashSector13,
Fapi_FlashSector14,
Fapi_FlashSector15,
Fapi_FlashSector16,
Fapi_FlashSector17,
Fapi_FlashSector18,
Fapi_FlashSector19,
Fapi_FlashSector20,
Fapi_FlashSector21,
Fapi_FlashSector22,
Fapi_FlashSector23,
Fapi_FlashSector24,
Fapi_FlashSector25,
Fapi_FlashSector26,
Fapi_FlashSector27,
Fapi_FlashSector28,
Fapi_FlashSector29,
Fapi_FlashSector30,
Fapi_FlashSector31,
Fapi_FlashSector32,
Fapi_FlashSector33,
Fapi_FlashSector34,
Fapi_FlashSector35,
Fapi_FlashSector36,
Fapi_FlashSector37,
Fapi_FlashSector38,
Fapi_FlashSector39,
Fapi_FlashSector40,
Fapi_FlashSector41,
Fapi_FlashSector42,
44
Typedefs and EnumerationsSPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comEnumerationsFapi_FlashSector43,
Fapi_FlashSector44,
Fapi_FlashSector45,
Fapi_FlashSector46,
Fapi_FlashSector47,
Fapi_FlashSector48,
Fapi_FlashSector49,
Fapi_FlashSector50,
Fapi_FlashSector51,
Fapi_FlashSector52,
Fapi_FlashSector53,
Fapi_FlashSector54,
Fapi_FlashSector55,
Fapi_FlashSector56,
Fapi_FlashSector57,
Fapi_FlashSector58,
Fapi_FlashSector59,
Fapi_FlashSector60,
Fapi_FlashSector61,
Fapi_FlashSector62,
Fapi_FlashSector63
}
ATTRIBUTE_PACKED Fapi_FlashSectorType;
B.2.9Fapi_FlashStateCommandsTypeThis contains all the possible Flash State Machine commands.
typedef enum
{
Fapi_ProgramData
= 0x0002,
Fapi_EraseSector
= 0x0006,
Fapi_EraseBank
= 0x0008,
Fapi_ValidateSector = 0x000E,
Fapi_ClearStatus
= 0x0010,
Fapi_ProgramResume
= 0x0014,
Fapi_EraseResume
= 0x0016,
Fapi_ClearMore
= 0x0018
}
ATTRIBUTE_PACKED Fapi_FlashStateCommandsType;
B.2.10Fapi_FlashReadMarginModeTypeThis contains all the possible Flash State Machine commands.
typedef enum
{
Fapi_NormalRead = 0x0,
Fapi_RM0
= 0x1,
Fapi_RM1
= 0x2
}
ATTRIBUTE_PACKED Fapi_FlashReadMarginModeType;
SPNU501F – December 2012 – Revised May 2014
Typedefs and Enumerations45
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
Enumerationswww.ti.comB.2.11Fapi_StatusTypeThis is the master type containing all possible returned status codes.
typedef enum
{
Fapi_Status_Success=0,
/* Function completed successfully */
Fapi_Status_FsmBusy,
/* FSM is Busy */
Fapi_Status_FsmReady,
/* FSM is Ready */
Fapi_Error_Fail,
/* Generic Function Fail code */
Fapi_Error_NullPointer,
/* One of the pointer parameters is a null pointer */
Fapi_Error_InvalidCommand,
/* Command used is invalid for the function called */
Fapi_Error_InvalidEccAddress,
/* Returned if the ECC Address given to a function is
invalid for that function */
Fapi_Error_OtpChecksumMismatch,
/* Returned if OTP checksum does not match expected value */
Fapi_Error_InvalidHclkValue,
/* Returned if FClk is above max FClk value -
FClk is a calculated from HClk and
RWAIT/EWAIT */
Fapi_Error_InvalidBank,
/* Returned if the specified bank does not exist */
Fapi_Error_InvalidAddress,
/* Returned if the specified Address does not exist in
Flash or OTP */
Fapi_Error_InvalidReadMode,
/* Returned if the specified read mode does not exist */
Fapi_Error_AsyncIncorrectDataBufferLength,
/* Returned if Data buffer size specified
exceeds Data bank width */
Fapi_Error_AsyncIncorrectEccBufferLength,
/* Returned if ECC buffer size specified
exceeds ECC bank width */
Fapi_Error_AsyncDataEccBufferLengthMismatch, /* Returned if Data buffer size either is not
64bit aligned or Data
length exceeds amount ECC supplied */
Fapi_Error_FeatureNotAvailable
/* FMC feature is not available on this device */
}
ATTRIBUTE_PACKED Fapi_StatusType;
B.2.12Fapi_ApiProductionStatusTypeThis lists the different production status values possible for the API.
typedef enum
{
Alpha_Internal,
/* For internal TI use only.
Not intended to be used by customers
*/
Alpha,
/* Early Engineering release.
May not be functionally complete */
Beta_Internal,
/* For internal TI use only.
Not intended to be used by customers
*/
Beta,
/* Functionally complete, to be used for testing and validation */
Production
/* Fully validated, functionally complete, ready for production use
*/
}
ATTRIBUTE_PACKED Fapi_ApiProductionStatusType;
46
Typedefs and EnumerationsSPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAppendix C Flash Validation ProcedureTI distributes the F021 Flash API as pre-compiled object libraries which has been fully qualified for use on
Hercules devices. This ensures that the object code for programming will be the same as was qualified by
TI. However it might be still possible that the application program does not use the API functions correctly
by either passing incorrect values or using the API functions in a manner not in accordance with the API
documentation. In order to ensure proper usage of the Flash API, the in application and 3rd programming
tools must be validated.
1. Erase and program at least 4 devices with customer's object code using the method selected by the
customer for programming.
2. Using the TI profiling tool (contact local TI representative to obtain), generate profiles for each device
programmed in 1.
3. Erase and program these devices again using the same data pattern used in step 1 with the TI tool,
UniFlash.
4. Repeat step 2 on the devices programmed with UniFlash.
The profiles generated in steps 2 and 4 should correlate within 100mV or 18 indices on the 0's Vt and be
within 3 indices on the 1's BCC.
NOTE:It is also highly recommended that the F021 Flash API usage be thouroughly reviewed by
someone who was not involved with writing the code for Flash usage.
SPNU501F – December 2012 – Revised May 2014
Flash Validation Procedure47
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAppendix D Parallel Signature Analysis (PSA) algorithmThe functions
Section 3.4.6 and
Section 3.4.5 make use of the Parallel Signature Analysis (PSA) algoritm.
Those functions are typically used to verify a particular pattern is programmed in the Flash Memory
without transferring the complete data pattern. The PSA signature is based on this primative polynomial:
f(X) = 1 + X + X2 + X22 + X31
uint32_t calculatePSA (uint32_t* pu32StartAddress,
uint32_t
u32Length,
/* Number of 32bit words */
uint32_t
u32InitialSeed)
{
uint32_t u32Seed, u32SeedTemp;
u32Seed = u32InitialSeed;
while(u32Length--)
{
u32SeedTemp = (u32Seed << 1)^*(pu32StartAddress++);
if(u32Seed & 0x80000000)
{
u32SeedTemp ^= 0x00400007;
/* XOR the seed value with mask */
}
u32Seed = u32SeedTemp;
}
return u32Seed;
}
48
Parallel Signature Analysis (PSA) algorithmSPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
www.ti.comAppendix E Revision HistoryTable 10 lists the API versions.
Table 10. API Version HistoryVersionAdditions/Modifications/Deletions1.00.0
Initial Revision
1.00.1
Added missing extern reference for Fapi_getBankSectors()
• Added support for Concerto devices.
• Corrected issue with with Fapi_doBlankCheck() and Fapi_doVerify that could cause an illegal address
1.50.0
abort.
• Added ECC read support for 72-bit wide FLEE banks
• SDOCM00086276 - Changed the u64Data parameter passed to Fapi_calculateEcc() to be consistent
behavior on Big and Little Endian Systems.
• SDOCM00087304 - Updated Fapi_doBlankCheck to use Read Margin mode 0 only.
• SDOCM00086404 - Added macro FAPI_WRITE_LOCKED_FSM_REGISTER() to allow easier writes to
locked register in the Flash Memory Controller.
• SDOCM00086405 - Changed the functions Fapi_setupEepromSectorEnable() and
Fapi_setupBankSectorEnable() in Fapi_UserDefinedFunctions.c to use the macro
1.51.0
FAPI_WRITE_LOCKED_FSM_REGISTER() as the register that were being written to are locked
register in the Flash Memory Controller.
• SDOCM00086402 - Corrected the issue in Fapi_doMarginRead() that did not return all the requested
data in the ECC memory regions.
• SDOCM00088256 - Changed the check that insures max FCLK value for the device is not exceeded
from a defined constant in the API to a check from the device OTP value.
• SDOCM00087302 - Updated the structures in Types.h to support linking in gcc toolchain.
• Replaced the user defined callback functions Fapi_setupEepromSectorEnable() and
Fapi_setupBankSectorEnable() with the functions Fapi_enableEepromBankSectors() and
Fapi_enableMainBankSectors.
• Deprecated the function Fapi_waitDelay().
• Removed the header files F021_FMC_BE.h and F021_FMC_LE.h as F021.h has been updated to
automatically determine compile endianness.
• Replaced the Fapi_initializeAPI() function with Fapi_initializeFlashBanks(). With this change, all global
variables have been removed from the API.
• Added the Compatibility.h header file. This file contains some backwards compatibility macros to work
with projects that were previously built with v1.51 of the API. The list of functions and global variables
with compatibility defines are:
2.00.00
–
Fapi_initializeAPI()
–
Fapi_getFsmStatus()
–
Fapi_issueFsmSuspendCommand()
–
Fapi_writeEwaitValue(mEwait)
–
Fapi_checkFsmForReady()
–
Fapi_GlobalInit.m_poFlashControlRegisters
• Fapi_getBankSectors() was updated to return sector sizes in kilobytes and to support 256kB sectors,
au8SectorSizes which was an array uint8_t was changed to an array of uint16_t and renamed
au16SectorSizes.
SPNU501F – December 2012 – Revised May 2014
Revision History49
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
Appendix Ewww.ti.comTable 10. API Version History (continued)VersionAdditions/Modifications/Deletions• Added Fapi_remapMainAddress() to give an easy method to determine ECC address for a main flash
address
• Removed unused status' from Fapi_StatusType
–
Fapi_Status_AsyncBusy
–
Fapi_Status_AsyncComplete
–
Fapi_Error_StateMachineTimeout
2.00.00
–
Fapi_Error_InvalidDelayValue
–
Fapi_Error_InvalidCpu
• Removed the listing of structures. Please refer to the installed F021 Flash API headers files for these.
• Changed from the use of defined typedefs uint64, uint32, uint16, and uint8 to the standard definitions in
stdint.h, uint64_t, uint32_t, uint16_t, and uint8_t. Also changed boolean to boolean_t
• Added #if defined guardbanding around the defines in Types.h that can conflict with Autosar
Platform_Types.h defines.
• Added appendix describing the PSA calculation
• Corrected the function description for Fapi_enableMainBanks().
2.00.01
• Added additional files that are distributed with the library.
• Added additional library files for L2FMC with floating point support.
• SDOCM00102756 - Remove FLOCK register from register include file.
2.01.00
• SDOCM00103134 - Sector size returned for FLEE banks by Fapi_getBankSectors() is double the
actual size.
Table 11 lists the API changes made since the previous revision of this document.
Table 11. Document Revision HistoryReferenceAdditions/Modifications/Deletions-
Initial revision
A
Updated for v1.50.0
B
Updated the example code for Fapi_issueProgrammingCommand()
C
Updated for v1.51.0
D
Updated for v2.00.00
E
Updated for v2.00.01
• Added the Validation procedure
F
• Corrected the register field name to disable ECC on bank 7 before calling a Blank Check function.
G
Updated for v2.01.00
50
Revision HistorySPNU501F – December 2012 – Revised May 2014
Submit Documentation FeedbackCopyright © 2012–2014, Texas Instruments Incorporated
IMPORTANT NOTICETexas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, enhancements, improvements and other
changes to its semiconductor products and services per JESD46, latest issue, and to discontinue any product or service per JESD48, latest
issue. Buyers should obtain the latest relevant information before placing orders and should verify that such information is current and
complete. All semiconductor products (also referred to herein as “components”) are sold subject to TI’s terms and conditions of sale
supplied at the time of order acknowledgment.
TI warrants performance of its components to the specifications applicable at the time of sale, in accordance with the warranty in TI’s terms
and conditions of sale of semiconductor products. Testing and other quality control techniques are used to the extent TI deems necessary
to support this warranty. Except where mandated by applicable law, testing of all parameters of each component is not necessarily
performed.
TI assumes no liability for applications assistance or the design of Buyers’ products. Buyers are responsible for their products and
applications using TI components. To minimize the risks associated with Buyers’ products and applications, Buyers should provide
adequate design and operating safeguards.
TI does not warrant or represent that any license, either express or implied, is granted under any patent right, copyright, mask work right, or
other intellectual property right relating to any combination, machine, or process in which TI components or services are used. Information
published by TI regarding third-party products or services does not constitute a license to use such products or services or a warranty or
endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property of the
third party, or a license from TI under the patents or other intellectual property of TI.
Reproduction of significant portions of TI information in TI data books or data sheets is permissible only if reproduction is without alteration
and is accompanied by all associated warranties, conditions, limitations, and notices. TI is not responsible or liable for such altered
documentation. Information of third parties may be subject to additional restrictions.
Resale of TI components or services with statements different from or beyond the parameters stated by TI for that component or service
voids all express and any implied warranties for the associated TI component or service and is an unfair and deceptive business practice.
TI is not responsible or liable for any such statements.
Buyer acknowledges and agrees that it is solely responsible for compliance with all legal, regulatory and safety-related requirements
concerning its products, and any use of TI components in its applications, notwithstanding any applications-related information or support
that may be provided by TI. Buyer represents and agrees that it has all the necessary expertise to create and implement safeguards which
anticipate dangerous consequences of failures, monitor failures and their consequences, lessen the likelihood of failures that might cause
harm and take appropriate remedial actions. Buyer will fully indemnify TI and its representatives against any damages arising out of the use
of any TI components in safety-critical applications.
In some cases, TI components may be promoted specifically to facilitate safety-related applications. With such components, TI’s goal is to
help enable customers to design and create their own end-product solutions that meet applicable functional safety standards and
requirements. Nonetheless, such components are subject to these terms.
No TI components are authorized for use in FDA Class III (or similar life-critical medical equipment) unless authorized officers of the parties
have executed a special agreement specifically governing such use.
Only those TI components which TI has specifically designated as military grade or “enhanced plastic” are designed and intended for use in
military/aerospace applications or environments. Buyer acknowledges and agrees that any military or aerospace use of TI components
which have
not been so designated is solely at the Buyer's risk, and that Buyer is solely responsible for compliance with all legal and
regulatory requirements in connection with such use.
TI has specifically designated certain components as meeting ISO/TS16949 requirements, mainly for automotive use. In any case of use of
non-designated products, TI will not be responsible for any failure to meet ISO/TS16949.
ProductsApplicationsAudio
www.ti.com/audioAutomotive and Transportation
www.ti.com/automotiveAmplifiers
amplifier.ti.comCommunications and Telecom
www.ti.com/communicationsData Converters
dataconverter.ti.comComputers and Peripherals
www.ti.com/computersDLP® Products
www.dlp.comConsumer Electronics
www.ti.com/consumer-appsDSP
dsp.ti.comEnergy and Lighting
www.ti.com/energyClocks and Timers
www.ti.com/clocksIndustrial
www.ti.com/industrialInterface
interface.ti.comMedical
www.ti.com/medicalLogic
logic.ti.comSecurity
www.ti.com/securityPower Mgmt
power.ti.comSpace, Avionics and Defense
www.ti.com/space-avionics-defenseMicrocontrollers
microcontroller.ti.comVideo and Imaging
www.ti.com/videoRFID
www.ti-rfid.comOMAP Applications Processors
www.ti.com/omapTI E2E Communitye2e.ti.comWireless Connectivity
www.ti.com/wirelessconnectivityMailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2014, Texas Instruments Incorporated
Document Outline