TMS320F28004x Flash API

TMS320F28004x Flash API
TMS320F28004x Flash API
Version 1.56.00.00
Reference Guide
Literature Number: SPNU628
February 2017
Contents
1
2
3
Introduction ......................................................................................................................... 4
1.1
Reference Material ....................................................................................................... 4
1.2
Function Listing Format
.................................................................................................
2.1
Introduction................................................................................................................ 6
2.2
API Overview ............................................................................................................. 6
2.3
Using API.................................................................................................................. 7
API Functions ...................................................................................................................... 9
3.1
Initialization Functions ................................................................................................... 9
3.2
Flash State Machine Functions ....................................................................................... 10
..............................................................................................
3.4
Program Functions .....................................................................................................
3.5
Read Functions .........................................................................................................
3.6
Informational Functions ................................................................................................
3.7
Utility Functions .........................................................................................................
4
Recommended FSM Flows ..................................................................................................
4.1
New devices from Factory .............................................................................................
4.2
Recommended Erase Flow............................................................................................
4.3
Recommended Program Flow ........................................................................................
Appendix A Flash State Machine Commands .................................................................................
A.1
Flash State Machine Commands....................................................................................
Appendix B Object Library Function Information............................................................................
B.1
TMS320F28004x Flash API Library.................................................................................
Appendix C Typedefs, Defines, Enumerations and Structures .........................................................
C.1
Type Definitions .......................................................................................................
C.2
Defines ..................................................................................................................
C.3
Enumerations ..........................................................................................................
C.4
Structures...............................................................................................................
Appendix D Parallel Signature Analysis (PSA) Algorithm ................................................................
D.1
Function Details .......................................................................................................
3.3
2
4
C2000 F021 Flash API Overview ............................................................................................. 6
Asynchronous Functions
Table of Contents
15
17
21
25
26
26
26
27
28
29
29
30
30
32
32
32
33
37
38
38
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
www.ti.com
List of Figures
1
Recommended Erase Flow ............................................................................................... 27
2
Recommended Program Flow ............................................................................................ 28
List of Tables
1
Summary of Initialization Functions ....................................................................................... 6
2
Summary of Flash State Machine Functions ............................................................................. 6
3
Summary of Asynchronous Operation Functions ........................................................................ 6
4
Summary of Programming Functions ..................................................................................... 6
5
Summary of Read Functions ............................................................................................... 6
6
Summary of Information Functions ........................................................................................ 7
7
Summary of Utility Functions ............................................................................................... 7
8
FMSTAT Register .......................................................................................................... 10
9
FMSTAT Register Field Descriptions .................................................................................... 10
10
Flash State Machine Commands
11
C28x Function Sizes and Stack Usage
........................................................................................
.................................................................................
SPNU628 – February 2017
Submit Documentation Feedback
List of Figures
Copyright © 2017, Texas Instruments Incorporated
29
30
3
Reference Guide
SPNU628 – February 2017
1
Introduction
This reference guide provides a detailed description of Texas Instruments' TMS320F28004x Flash API
functions that can be used to erase, program and verify Flash on TMS320F28004x devices.
1.1
Reference Material
Use this guide in conjunction with the device-specific data manual and technical reference manual that is
being used.
1.2
Function Listing Format
This is the general format of an entry for a function, compiler intrinsic, or macro.
A short description of what function function_name() does.
Synopsis
Provides a prototype for function function_name().
<return_type> function_name(
<type_1> parameter_1,
<type_2> parameter_2,
<type_n> parameter_n
)
Parameters
parameter_1 [in]
parameter_2 [out]
parameter_n [in/out]
Pointer to x
Handle for y
Pointer to z
Parameter passing is categorized as follows:
• In — Indicates the function uses one or more values in the parameter that you give it without storing
any changes.
• Out — Indicates 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 — Indicates 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.
Description
Describes 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
Restrictions
Specifies any restrictions in using this function
4
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
Introduction
www.ti.com
Return Value
Specifies any value or values returned by function function_name().
See Also
Lists other functions or data types related to function function_name().
Example
Provides an example (or a reference to an example) that illustrates the use of function function_name().
5
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
C2000 F021 Flash API Overview
www.ti.com
2
C2000 F021 Flash API Overview
2.1
Introduction
Flash API is a library of routines, that when called with the proper parameters in the proper sequence,
erases, programs, or verifies Flash memory. The API verifies that the appropriate RWAIT (waitstate) value
is set for the specified system frequency.
NOTE: Please refer to the C2000 device-specific technical reference manual and data manual for
more details regarding waitstates.
2.2
API Overview
Table 1. Summary of Initialization Functions
API Function
Description
Fapi_initializeAPI()
Initializes the API for first use or frequency change
Table 2. Summary of Flash State Machine Functions
API Function
Description
Fapi_getFsmStatus()
Returns the FMSTAT status register value from the Flash memory controller
Fapi_checkFsmForReady()
Returns whether or not the Flash state machine (FSM) is ready or busy
Fapi_setActiveFlashBank()
Initializes Flash Memory Controller (FMC) and banks for an erase or program
command
Fapi_issueFsmSuspendCommand()
Suspends FSM commands program data and erase sector
Fapi_flushPipeline()
Flushes the data cache in FMC
Fapi_isAddressEcc()
Determines if the address falls in ECC ranges
Fapi_remapEccAddress()
Remaps an ECC address to corresponding main address
Table 3. Summary of Asynchronous Operation Functions
API Function
Description
Fapi_issueAsyncCommandWithAddress()
Issues an erase sector command to FSM for the given address
Fapi_issueAsyncCommand()
Issues a command (Clear Status, Program Resume, Erase Resume, Clear_More)
to FSM for operations that do not require an address
Table 4. Summary of Programming Functions
API Function
Description
Fapi_issueProgrammingCommand()
Sets up the required registers for programming and issues the
command to the FSM
Fapi_issueProgrammingCommandForEccAddress()
Remaps an ECC address to the main data space and then call
Fapi_issueProgrammingCommand() to program ECC
Table 5. Summary of Read Functions
API Function
Description
Fapi_doVerify()
Verifies specified Flash memory range against supplied values
Fapi_doBlankCheck()
Verifies specified Flash memory range against erased state
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
6
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
C2000 F021 Flash API Overview
www.ti.com
Table 6. Summary of Information Functions
API Function
Description
Fapi_getLibraryInfo()
Returns the information specific to the compiled version of the API library
Note that Fapi_getDeviceInfo() and Fapi_getBankSectors() are removed in TMS320F28004x Flash API
since users can obtain this information (for example, number of banks, pin count, number of sectors, and
so on, from other resources provided in the TRM).
Table 7. Summary of Utility Functions
API Function
Description
Fapi_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_UserDefinedFunctions.c file is not provided anymore since the functions in that file are now merged
in the Flash API Library. Review Section 2.3.3 for information about servicing the watchdog function while
using Flash API.
2.3
Using API
This section describes the flow for using various API functions.
2.3.1
Initialization Flow
2.3.1.1
After Device Power Up
After the device is initially powered up, the function Fapi_initializeAPI() must be called before any other
API function can be used except for the function Fapi_getLibraryInfo(). This initializes the API internal
structures.
2.3.1.2
Bank Setup
Before performing a Flash operation for the first time, the function Fapi_setActiveFlashBank() must be
called.
2.3.1.3
On System Frequency Change
If the System operating frequency is changed after the initial call to the function Fapi_initializeAPI(), this
function must be called again before any other API function except Fapi_getLibraryInfo() can be used.
This will update the API internal state variables.
2.3.2
Building With the API
2.3.2.1
Object Library Files
C28x Flash API object files are distributed in the standard TI COFF object format.
2.3.2.2
Distribution Files
The following API files are distributed with the installer:
• Library Files
– F021_API_F28004x_FPU32.lib – This is the Flash API object file for TMS320F28004x devices that
are using the floating point unit.
• Include Files
– This file sets up compile-specific defines and then includes the F021.h master include file.
• F021_F28004x_C28x.h – The master include file for TMS320F28004x devices.
7
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
C2000 F021 Flash API Overview
•
www.ti.com
The following include files should not be included directly by the user’s code, but are listed here for
user reference:
– F021.h – This include file lists all public API functions and includes all other include files.
– Init.h – Defines the API initialization structure.
– Registers_C28x.h – Little Endian Flash memory controller registers structure.
– Registers.h – Definitions common to all register implementations and includes the appropriate
register include file for the selected device type.
– Types.h – Contains all the enumerations and structures used by the API.
– Constants/Constants.h – Constant definitions common to all F021x devices.
– Constants/F28004x.h – Constant definitions for F28004x devices.
Note that Helpers.h is not provided since it is not needed for user applications.
2.3.3
Quick Facts About API Usage
Here are some important facts about API usage:
• Names of the Flash API functions start with a prefix “Fapi_”.
• Flash API does not configure PLL. The user application should configure the PLL as needed and pass
the configured CPUCLK value to Fapi_initializeAPI() function (details of this function are given later in
this document).
• Flash wait-states (refer to the data manual) must be configured before calling Flash API functions.
• Flash API execution is interruptible. However, there should not be any read/fetch access from the
Flash bank on which an erase/program operation is in progress. In single-bank devices, Flash API
must be executed from RAM. In dual-bank devices, Flash API can execute from one bank to perform
erase/program operations on another bank.
• Flash API does not configure (enable/disable) watchdog. The user application can configure watchdog
and service it as needed. Hence, the Fapi_ServiceWatchdogTimer() function is no longer provided.
• Flash API uses EALLOW and EDIS internally as needed to allow/disallow writes to protected registers.
• The Main Array flash programming must be aligned to 64-bit address boundaries and each 64-bit word
may only be programmed once per write/erase cycle.
• It is alright to program the data and ECC separately. However, each 64-bit dataword and 16-bit ECC
word may only be programmed once per write/erase cycle.
• The DCSM OTP programming must be aligned to 128-bit address boundaries and each 128-bit word
may only be programmed once. The exceptions are:
– The DCSM Zx-LINKPOINTER1 and Zx-LINKPOINTER2 values in the DCSM OTP should be
programmed together, and may be programmed 1 bit at a time as required by the DCSM operation.
– The DCSM Zx-LINKPOINTER3 values in the DCSM OTP may be programmed 1 bit at a time on a
64-bit boundary to separate it from Zx-PSWDLOCK, which must only be programmed once.
• There is no pump semaphore in TMS320F28004x devices.
• ECC should not be programmed for LINKPOINTER locations. Use Fapi_DataOnly mode for
programming these locations.
• When using INTOSC as the clock source, a few SYSCLK frequency ranges need an extra waitstate to
perform erase and program operations. After the operation is over, that extra waitstate is not needed.
Please refer to the data manual for more details.
• Always configure waitstates as per the data manual before calling Flash API functions.
8
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
www.ti.com
3
API Functions
3.1
Initialization Functions
3.1.1
Fapi_initializeAPI()
Initializes the Flash API
Synopsis
Fapi_StatusType Fapi_initializeAPI(
Fapi_FmcRegistersType *poFlashControlRegister,
uint32 u32HclkFrequency)
Parameters
poFlashControlRegister [in]
u32HclkFrequency [in]
Pointer to the Flash Memory Controller Registers' base address
System clock frequency in MHz
Description
This function is required to initialize the Flash API before any other Flash API operation is performed. This
function must also be called when System frequency is changed, or RWAIT values are changed.
NOTE: RWAIT register value must be set before calling this function.
Return Value
• Fapi_Status_Success (success)
Sample Implementation
#include “F021_F28004x_C28x.h”
#define HCLK_FREQUENCY 100 /* 100 MHz
int main(void)
{
Fapi_StatusType oReturnCheck;
System frequency */
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,HCLK_FREQUENCY);
/* User code for flash operations */
}
9
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
3.2
3.2.1
www.ti.com
Flash State Machine Functions
Fapi_getFsmStatus()
Returns the value of the FMSTAT register
Synopsis
Fapi_FlashStatusType Fapi_getFsmStatus(void)
Parameters
None
Description
This function returns the value of the FMSTAT register. The user application should check the value of this
register to know if there is any failure occurrence for the current operation.
Return Value
Table 8. FMSTAT Register
Bits
31
...
15
Rsvd
14
ILA
13
Rsvd
12
PGV
11
Rsvd
10
EV
9
Rsvd
8
Busy
7
ERS
6
5
PGM
INV
DAT
4
3
2
1
0
CSTAT
Volt
Stat
ESUSP
PSUSP
Rsvd
Table 9. FMSTAT Register Field Descriptions
Bit
Field
Description
31-15
RSVD
Reserved
14
ILA
Illegal Address. When set, indicates that an illegal address is detected. The conditions below can
set an illegal address flag:
• Writing to an address location in an unimplemented flash space.
• The address range does not match the type of FSM command.
13
RSVD
Reserved
12
PGV
Program verify. When set, indicates that a word is not successfully programmed after the maximum
allowed number of program pulses are given for program operation.
11
RSVD
Reserved
10
EV
Erase verify. When set, indicates that a sector is not successfully erased after the maximum
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
RSVD
Reserved
8
Busy
When set, this bit indicates that a program, erase, or suspend operation is being processed.
7
ERS
Erase Active. When set, this bit indicates that the flash module is actively performing an erase
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.
6
PGM
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 complete. It
is also cleared when programming is suspended and set when programming is resumes.
5
INVDAT
Invalid Data. When set, this bit indicates that the user attempted to program a “1” where a “0” was
already present. This bit is cleared by the Clear Status command.
4
CSTAT
Command Status. Once the FSM starts any failure will set this bit. When set, this bit informs the
host that the program or erase command failed and the command was stopped. 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.
3
VOLTSTAT
Core Voltage Status. When set, this bit indicates that the core voltage generator of the pump power
supply dipped below the lower limit allowable during a program or erase operation. This bit is
cleared by the Clear Status command.
10
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
www.ti.com
Table 9. FMSTAT Register Field Descriptions (continued)
Bit
Field
Description
2
ESUSP
Erase Suspend. When set, this bit indicates that the flash module has received and processed an
erase suspend operation. This bit remains set until the erase resume command has been issued or
until the Clear_More command is run.
1
PSUSP
Program Suspend. When set, this bit indicates that the flash module has received and processed a
program suspend operation. This bit remains set until the program resume command has been
issued or until the Clear_More command is run.
0
RSVD
RSVD
11
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
3.2.2
www.ti.com
Fapi_checkFsmForReady()
Returns the status of the Flash State Machine
Synopsis
Fapi_StatusType Fapi_checkFsmForReady(void)
Parameters
None
Description
This function returns the status of the Flash State Machine indicating if it is ready to accept a new
command or not. The primary use is to check if an Erase or Program operation has finished.
Return Value
• Fapi_Status_FsmBusy (FSM is busy and cannot accept new command except for suspend
commands)
• Fapi_Status_FsmReady (FSM is ready to accept new command)
3.2.3
Fapi_setActiveFlashBank()
Initializes the FMC and banks for erase and program operations
Synopsis
Fapi_StatusType Fapi_setActiveFlashBank(
Fapi_FlashBankType oNewFlashBank)
Parameters
oNewFlashBank [in]
Fapi_FlashBank0 should be used. This will configure FMC for both
banks. No need to call this function with Fapi_FlashBank1 as the
parameter.
Description
This function sets the FMC and banks for further Flash operations to be performed.
Return Value
• Fapi_Status_Success (Success)
• Fapi_Error_InvalidBank (failure: Bank specified does not exist on device)
• 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)
Sample Implementation
#include "F021_F28004x_C28x.h"
int main(void)
{
Fapi_StatusType oReturnCheck;
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
/* User code for flash operations */
}
12
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
www.ti.com
3.2.4
Fapi_issueFsmSuspendCommand()
Issues Flash State Machine suspend command
Synopsis
Fapi_StatusType Fapi_issueFsmSuspendCommand(void)
Parameters
None
Description
This function issues a suspend now command which will suspend the FSM commands, Program and
Erase Sector, when they are the current active command. Use Fapi_getFsmStatus() to check to see if the
operation is successful.
Return Value
• Fapi_Status_Success (success)
3.2.5
Fapi_flushPipeline()
Flushes the FMC pipeline buffers
Synopsis
void Fapi_flushPipeline(void)
Parameters
None
Description
This function flushes the FMC data cache. The data cache must be flushed before the first non-API Flash
read after an erase or program operation.
Return Value
None
13
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
3.2.6
www.ti.com
Fapi_remapEccAddress()
Takes ECC address and remaps it to main address space
Synopsis
uint32 Fapi_remapEccAddress(
uint32 u32EccAddress)
Parameters
u32EccAddress [in]
ECC address to remap
Description
This function returns the main Flash address for the given ECC Flash address.
Return Value
• 32-bit Main Flash Address
3.2.7
Fapi_isAddressEcc()
Indicates is an address is in the Flash Memory Controller ECC space
Synopsis
boolean Fapi_isAddressEcc(
uint32 u32Address)
Parameters
u32Address [in]
Address to determine if it lies in ECC address space
Description
This function returns True if address 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)
14
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
www.ti.com
3.3
Asynchronous Functions
3.3.1
Fapi_issueAsyncCommandWithAddress()
Issues an erase command to the Flash State Machine along with a user-provided sector address.
Synopsis
Fapi_StatusType Fapi_issueAsyncCommandWithAddress(
Fapi_FlashStateCommandsType oCommand,
uint32 *pu32StartAddress)
Parameters
oCommand [in]
pu32StartAddress [in]
Command to issue to the FSM. Use Fapi_EraseSector
Address needed for Flash State Machine operation
Description
This function issues an erase command to the Flash State Machine for the user-provided sector address.
NOTE: This function does not check FMSTAT after issuing the erase command. The user
application must check the FMSTAT value when FSM has completed the erase operation.
FMSTAT indicates if there is any failure occurrence during the erase operation. The user
application can use the Fapi_getFSMStatus function to obtain the FMSTAT value.
Return Value
• Fapi_Status_Success (success)
• Fapi_Error_FeatureNotAvailable (failure: User requested a command that is not supported)
• Fapi_Error_FlashRegsNotWritable (failure: Flash register write failed. The user should make sure
that the API is executing from the same zone as that of the target address for flash operation OR the
user should unlock before the flash operation)
Sample Implementation
#include “F021_F28004x_C28x.h”
#define HCLK_FREQUENCY 100 /* 100 MHz System frequency */
int main(void)
{
Fapi_StatusType oReturnCheck;
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,HCLK_FREQUENCY);
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,
(uint32 *) 0x0080000);
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
/* User code for flash operations */
}
15
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
3.3.2
www.ti.com
Fapi_issueAsyncCommand()
Issues a command to the Flash State Machine
Synopsis
Fapi_StatusType Fapi_issueAsyncCommand(
Fapi_FlashStateCommandsType oCommand)
Parameters
oCommand [in]
Command to issue to the FSM
Description
This 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.
NOTE: This function does not check FMSTAT after issuing the command. The user application must
check the FMSTAT value when FSM has completed the operation. FMSTAT indicates if
there is any failure occurrence during the operation. The user application can use the
Fapi_getFSMStatus function to obtain the FMSTAT value.
Return Value
• Fapi_Status_Success (success)
Sample Implementation
#include “F021_F28004x_C28x.h”
#define HCLK_FREQUENCY 100 /* 100 MHz System frequency */
int main(void)
{
Fapi_StatusType oReturnCheck;
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,HCLK_FREQUENCY);
oReturnCheck = Fapi_issueAsyncCommand(Fapi_ClearStatus);
/* User code for flash operations */
}
16
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
www.ti.com
3.4
3.4.1
Program Functions
Fapi_issueProgrammingCommand()
Sets up data and issues program command to valid Flash memory addresses
Synopsis
Fapi_StatusType Fapi_issueProgrammingCommand(
uint32 *pu32StartAddress,
uint16 *pu16DataBuffer,
uint16 u16DataBufferSizeInWords,
uint16 *pu16EccBuffer,
uint16 u16EccBufferSizeInBytes,
Fapi_FlashProgrammingCommandType oMode)
Parameters
pu32StartAddress [in]
pu16DataBuffer [in]
u16DataBufferSizeInWords [in]
pu16EccBuffer [in]
u16EccBufferSizeInBytes [in]
oMode [in]
start address in Flash for the data and ECC to be programmed
pointer to the Data buffer address
number of 16-bit words in the Data buffer
pointer to the ECC buffer address
number of bytes in the ECC buffer
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
Description
This 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. The pu16EccBuffer word corresponds
to the main array aligned on a 128-bit address boundary. The LSB of pu16EccBuffer corresponds to the
lower 64-bits of the main array and the MSB of pu16EccBuffer corresponds to the upper 64-bits of the
main array.
Programming modes:
Fapi_DataOnly – This mode will only program the data portion in Flash at the address specified. It can
program from 1-bit up to 8 16-bit words. However, review the restrictions provided for this function to know
the limitations of flash programming data size. The supplied starting address to program at plus the data
buffer length cannot cross the 128-bit aligned address boundary.
Fapi_AutoEccGeneration – This will program the supplied data portion in Flash along with automatically
generated ECC. The ECC is calculated for every 64-bit data aligned on a 64-bit memory boundary, and
data not supplied is treated as 0xFF. The data restrictions for Fapi_DataOnly also exist for this option.
17
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
www.ti.com
NOTE: Fapi_AutoEccGeneration mode will program the supplied data portion in Flash along with
automatically generated ECC. The ECC is calculated for 64-bit aligned address and the
corresponding 64-bit data. Any data not supplied is treated as 0xFFFF. Note that there are
practical implications of this when writing a custom programming utility that streams in the
output file of a code project and programs the individual sections one at a time into flash. If a
64-bit word spans more than one section (that is, contains the end of one section, and the
start of another), values of 0xFFFF cannot be assumed for the missing data in the 64-bit
word when programming the first section. When you go to program the second section, you
will not be able to program the ECC for the first 64-bit word since it was already (incorrectly)
computed and programmed using assumed 0xFFFF for the missing values. One way to
avoid this problem is to align all sections linked to flash on a 64-bit boundary in the linker
command file for your code project.
Here is an example:
SECTIONS
{
.text
:
.cinit :
.const :
.econst :
.pinit :
.switch :
}
>
>
>
>
>
>
FLASH,
FLASH,
FLASH,
FLASH,
FLASH,
FLASH,
PAGE
PAGE
PAGE
PAGE
PAGE
PAGE
=
=
=
=
=
=
0,
0,
0,
0,
0,
0,
ALIGN(4)
ALIGN(4)
ALIGN(4)
ALIGN(4)
ALIGN(4)
ALIGN(4)
If you do not align the sections in flash, you would need to track incomplete 64-bit words in a
section and combine with the words in other sections that complete the 64-bit word. This will
be difficult to do so it is recommended to align your sections on 64-bit boundaries.
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 64bit word and the length of data must correlate to the supplied
ECC. (For example, data buffer length is 4 words, the ECC buffer must be 1 byte).
The LSB of pu16EccBuffer corresponds to the lower 64-bits of the main array and the MSB of
pu16EccBuffer corresponds to the upper 64-bits of the main array.
Fapi_EccOnly – This mode will only program the ECC portion in Flash at the address specified. It can
program either 1 byte or 2 bytes (2 is max).
The LSB of pu16EccBuffer corresponds to the lower 64-bits of the main array and the MSB of
pu16EccBuffer corresponds to the upper 64-bits of the main array.
NOTE: The length of pu16DataBuffer and pu16EccBuffer cannot exceed 8 and 2, respectively.
NOTE: This function does not check FMSTAT after issuing the program command. The user
application must check the FMSTAT value when FSM has completed the program operation.
FMSTAT indicates if there is any failure occurrence during the program operation. The user
application can use the Fapi_getFSMStatus function to obtain the FMSTAT value.
Restrictions
• The Main Array flash programming must be aligned to 64-bit address boundaries and each 64-bit word
may only be programmed once per write/erase cycle.
• It is alright to program the data and ECC separately. However, each 64-bit dataword and 16-bit ECC
word may only be programmed once per write/erase cycle.
• The DCSM OTP programming must be aligned to 128-bit address boundaries and each 128-bit word
may only be programmed once. The exceptions are:
– The DCSM Zx-LINKPOINTER1 and Zx-LINKPOINTER2 values in the DCSM OTP should be
programmed together, and may be programmed 1 bit at a time as required by the DCSM operation.
– The DCSM Zx-LINKPOINTER3 values in the DCSM OTP may be programmed 1 bit at a time on a
18
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
www.ti.com
64-bit boundary to separate it from Zx-PSWDLOCK, which must only be programmed once.
Return Value
• Fapi_Status_Success (success)
• Fapi_Error_AsyncIncorrectDataBufferLength (failure: Data buffer size specifiedis incorrect)
• Fapi_Error_AsyncIncorrectEccBufferLength (failure: ECC buffer size specified is incorrect)
• Fapi_Error_AsyncDataEccBufferLengthMismatch (failure: Data buffer size either is not 64-bit
aligned or data length crosses the 128-bit aligned memory boundary)
• Fapi_Error_FlashRegsNotWritable (failure: Flash register writes failed. The user should make sure
that the API is executing frm the same zone as that of the target address for flash operation OR the
user should unlock before the flash operation.
Sample Implementation
#include “F021_F28004x_C28x.h”
int main(void)
{
uint16 au16DataBuffer[8] = {0x0001, 0x0203, 0x0405, 0x0607, 0x0809, 0x0A0B, 0x0C0D, 0x0E0F};
Fapi_FlashBankType oActiveFlashBank = Fapi_FlashBank0;
Fapi_StatusType oReturnCheck;
uint32 u32Index;
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,100);
if(oReturnCheck == Fapi_Status_Success)
{
oReturnCheck = Fapi_setActiveFlashBank(oActiveFlashBank);
if(oReturnCheck == Fapi_Status_Success)
{
for(u32Index = 0x80000;
(u32Index < 0x80040) && (oReturnCheck == Fapi_Status_Success);
u32Index+= 0x8)
{
oReturnCheck = Fapi_issueProgrammingCommand(
(uint32 *) u32Index,
au16DataBuffer,
0x8,
0,
0,
Fapi_AutoEccGeneration);
while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
oReturnCheck = Fapi_getFsmStatus();
}
}
}
}
19
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
3.4.2
www.ti.com
Fapi_issueProgrammingCommandForEccAddresses()
Remaps an ECC address to data address and calls Fapi_issueProgrammingCommand().
Synopsis
Fapi_StatusType Fapi_issueProgrammingCommandForEccAddress(
uint32 *pu32StartAddress,
uint16 *pu16EccBuffer,
uint16
u16EccBufferSizeInBytes)
Parameters
pu32StartAddress [in]
pu16EccBuffer [in]
u16EccBufferSizeInBytes [in]
ECC start address in Flash for the ECC to be programmed
pointer to the ECC buffer address
number of bytes in the ECC buffer
If the number of bytes is 1, LSB (ECC for lower 64 bits) gets
programmed. MSB alone cannot be programmed using this
function. If the number of bytes is 2, both LSB and MSB bytes
of ECC get programmed.
Description
This 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. The
LSB of pu16EccBuffer corresponds to the lower 64 bits of the main array and the MSB of pu16EccBuffer
corresponds to the upper 64 bits of the main array.
NOTE: The length of the pu16EccBuffer cannot exceed 2.
NOTE: This function does not check FMSTAT after issuing the program command. The user
application must check the FMSTAT value when FSM has completed the program operation.
FMSTAT indicates if there is any failure occurrence during the program operation. The user
application can use the Fapi_getFSMStatus function to obtain the FMSTAT value.
Return Value
• Fapi_Status_Success (success)
• Fapi_Error_AsyncIncorrectEccBufferLength (failure: Data buffer size specified is incorrect)
• Fapi_Error_FlashRegsNotWritable (failure: Flash register writes failed. The user should make sure
that the API is executing frm the same zone as that of the target address for flash operation OR the
user should unlock before the flash operation.
20
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
www.ti.com
3.5
3.5.1
Read Functions
Fapi_doBlankCheck()
Verifies region specified is erased value
Synopsis
Fapi_StatusType Fapi_doBlankCheck(
uint32 *pu32StartAddress,
uint32 u32Length,
Fapi_FlashStatusWordType *poFlashStatusWord)
Parameters
pu32StartAddress [in]
u32Length [in]
poFlashStatusWord [out]
->au32StatusWord[0]
->au32StatusWord[1]
->au32StatusWord[2]
->au32StatusWord[3]
start address for region to blank check
length of region in 32-bit words to blank check
returns the status of the operation if result is not
Fapi_Status_Success
address of first non-blank location
data read at first non-blank location
value of compare data (always 0xFFFFFFFF)
N/A
Description
This 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.
Restrictions
The region being blank-checked cannot cross bank address boundary.
Return Value
• Fapi_Status_Success (success)
• Fapi_Error_Fail (failure: region specified is not blank)
21
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
3.5.2
www.ti.com
Fapi_doVerify()
Verifies region specified against supplied data
Synopsis
Fapi_StatusType Fapi_doVerify(
uint32 *pu32StartAddress,
uint32 u32Length,
uint32 *pu32CheckValueBuffer,
Fapi_FlashStatusWordType *poFlashStatusWord)
Parameters
pu32StartAddress [in]
u32Length [in]
pu32CheckValueBuffer
[in]
poFlashStatusWord [out]
start address for region to verify
length of region in 32-bit words to verify
address of buffer to verify region against
->au32StatusWord[0]
->au32StatusWord[1]
->au32StatusWord[2]
->au32StatusWord[3]
returns the status of the operation if result is not
Fapi_Status_Success
address of first verify failure location
data read at first verify failure location
value of compare data
N/A
Description
This 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.
Restrictions
The 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
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
www.ti.com
3.5.3
Fapi_doPsaVerify()
Verifies region specified against specified PSA value
Synopsis
Fapi_StatusType Fapi_doPsaVerify(
uint32 *pu32StartAddress,
uint32 u32Length,
uint32 u32PsaValue,
Fapi_FlashStatusWordType *poFlashStatusWord)
Parameters
pu32StartAddress [in]
u32Length [in]
u32PsaValue [in]
poFlashStatusWord [out]
->au32StatusWord[0]
start address for region to verify PSA value
length of region in 32-bit words to verify PSA value
PSA value to compare region against
returns the status of the operation if result is not
Fapi_Status_Success
Actual PSA
Description
This 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 value is returned in the poFlashStatusWord
parameter.
Restrictions
The 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)
23
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
3.5.4
www.ti.com
Fapi_calculatePsa()
Calculates the PSA for a specified region
Synopsis
uint32 Fapi_calculatePsa(
uint32 *pu32StartAddress,
uint32 u32Length,
uint32 u32PsaSeed,
Fapi_FlashReadMarginModeType oReadMode)
Parameters
pu32StartAddress [in]
u32Length [in]
u32PsaSeed [in]
oReadMode [in]
start address for region to calculate PSA value
length of region in 32-bit words to calculate PSA value
seed value for PSA calculation
only normal mode is applicable. Use Fapi_NormalRead.
Description
This function calculates the PSA value for the region specified starting at pu32StartAddress for u32Length
32-bit words using u32PsaSeed value.
Restrictions
The region that the PSA is being calculated on cannot cross bank address boundary
Return Value
• PSA value
24
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
www.ti.com
3.6
3.6.1
Informational Functions
Fapi_getLibraryInfo()
Returns information about this compile of the Flash API
Synopsis
Fapi_LibraryInfoType Fapi_getLibraryInfo(void)
Parameters
None
Description
This 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. Minor version is 56 for F28004x
devices.
• 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 the tech type of
0x4
• u8ApiTechnologyRevision – Indicates the revision of the Technology supported by the API
• u8ApiEndianness – Indicates if this compile of the API is for Big Endian (0) or Little Endian (1) 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)
25
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
API Functions
3.7
3.7.1
www.ti.com
Utility Functions
Fapi_calculateFletcherChecksum()
Calculates the Fletcher checksum from the given address and length
Synopsis
uint32 Fapi_calculateFletcherChecksum(
uint16 *pu16Data,
uint16 u16Length)
Parameters
pu16Data [in]
u16Length [in]
Address to start calculating the checksum from
Number of 16-bit words to use in calculation
Description
This function generates a 32-bit Fletcher checksum starting at the supplied address for the number of 16bit words specified.
Return Value
• 32-bit Fletcher Checksum value
3.7.2
Fapi_calculateEcc()
Calculates the ECC for a 64-bit value
Synopsis
uint8 Fapi_calculateEcc(
uint32 u32Address,
uint64 u64Data)
Parameters
u32Address [in]
u64Data [in]
Address of the 64-bit value to calculate the ECC
64-bit value to calculate ECC on (should be in little endian
order)
Description
This function will calculate the ECC for a 64-bit aligned word including address. There is no need to
provide a left-shifted address to this function anymore. TMS320F28004x Flash API takes care of it.
Return Value
• 8-bit calculated ECC
4
Recommended FSM Flows
4.1
New devices from Factory
Devices 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.
26
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
Recommended FSM Flows
www.ti.com
4.2
Recommended Erase Flow
The following diagram describes the flow for erasing a sector(s) on a device. Please refer to Section 3.3.1
for further information.
Start
Call
Fapi_initializeAPI()
No
Fapi_checkFsmForReady() ! =
Fapi_Status_FsmBusy
Call
Fapi_setActiveFlashBank()
Execute other
code as
needed
Yes
Call
Fapi_issueAsyncCommandWithAddress()
Fapi_getFsmStatus()
!=0
No
DUT fails Erase
Yes
Yes
Another Sector to Erase?
No
Done
Figure 1. Recommended Erase Flow
27
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
Recommended FSM Flows
4.3
www.ti.com
Recommended Program Flow
The following diagram 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. Please refer to
Section 4.2 for further information.
Start
Call
Fapi_InitializeAPI()
No
Fapi_checkFsmForReady()
!=Fapi_Status_FsmBusy
Execute other
code as
needed
Call
Fapi_setActiveFlashBank()
Yes
Call
Fapi_issueProgrammingCommand()
Supplying address, data and mode
Fapi_getFsmStatus()
!=0
No
DUT fails program
Yes
More data to program?
Yes
No
Done
Figure 2. Recommended Program Flow
28
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
Appendix A
SPNU628 – February 2017
Flash State Machine Commands
A.1
Flash State Machine Commands
Table 10. Flash State Machine Commands
Command
Program
Data
Description
Enumeration Type
Used to program data to
any valid Flash address
API Call(s)
Fapi_ProgramData
Fapi_issueProgrammingCommand()
Fapi_issueProgrammingCommandForEccAddress()
Used to erase a Flash
Erase Sector sector located by the
specified address
Fapi_EraseSector
Fapi_issueAsyncCommandWithAddress()
Clear Status
Clears the status register
Fapi_ClearStatus
Fapi_issueAsyncCommand()
Program
Resume
Resumes a suspended
programming operation
Fapi_ProgramResume
Fapi_issueAsyncCommand()
Erase
Resume
Resumes a suspended
erase operation
Fapi_EraseResume
Fapi_issueAsyncCommand()
Clear More
Clears the status register
Fapi_ClearMore
Fapi_issueAsyncCommand()
SPNU628 – February 2017
Submit Documentation Feedback
Flash State Machine Commands
Copyright © 2017, Texas Instruments Incorporated
29
Appendix B
SPNU628 – February 2017
Object Library Function Information
B.1
TMS320F28004x Flash API Library
Table 11. C28x Function Sizes and Stack Usage
Function Name
30
Size In
Words
Worst
Case
Stack
Usage
Fapi_calculateEcc
TBD
TBD
Fapi_calculateFletcherChecksum
TBD
TBD
Fapi_calculatePsa
Includes references to the following functions
• Fapi_isAddressEcc
• Fapi_serviceWatchdogTimer
TBD
TBD
Fapi_checkFsmForReady
TBD
TBD
Fapi_doBlankCheck
Includes references to the following functions
• Fapi_flushPipeline
• Fapi_serviceWatchdogTimer
• Fapi_waitDelay
• Fapi_isAddressEcc
TBD
TBD
Fapi_doVerify
Includes references to the following functions
• Fapi_flushPipeline
• Fapi_serviceWatchdogTimer
• Fapi_waitDelay
• Fapi_isAddressEcc
TBD
TBD
Fapi_flushPipeline
Includes references to the following functions
• Fapi_waitDelay
TBD
TBD
Fapi_getFsmStatus
TBD
TBD
Fapi_getLibraryInfo
TBD
TBD
Fapi_initializeAPI
TBD
TBD
Fapi_isAddressEcc
TBD
TBD
Fapi_issueAsyncCommand
TBD
TBD
Fapi_issueAsyncCommandWithAddress
Includes references to the following functions
• Fapi_setupBankSectorEnable
• Fapi_setupEepromSectorEnable
TBD
TBD
Fapi_issueFsmSuspendCommand
TBD
TBD
Fapi_issueProgrammingCommand
Includes references to the following functions
• Fapi_calculateEcc
• Fapi_setupBankSectorEnable
• Fapi_setupEepromSectorEnable
TBD
TBD
Object Library Function Information
SPNU628 – February 2017
Submit Documentation Feedback
Copyright © 2017, Texas Instruments Incorporated
TMS320F28004x Flash API Library
www.ti.com
Table 11. C28x Function Sizes and Stack Usage (continued)
Fapi_issueProgrammingCommandForEccAddresses
Includes references to the following functions
• Fapi_calculateEcc
• Fapi_setupBankSectorEnable
• Fapi_setupEepromSectorEnable
• Fapi_remapEccAddress
TBD
TBD
Fapi_remapEccAddress
TBD
TBD
Fapi_setActiveFlashBank
Includes references to the following functions
• Fapi_calculateFletcherChecksum
TBD
TBD
SPNU628 – February 2017
Submit Documentation Feedback
Object Library Function Information
Copyright © 2017, Texas Instruments Incorporated
31
Appendix C
SPNU628 – February 2017
Typedefs, Defines, Enumerations and Structures
C.1
Type Definitions
#if defined(__TMS320C28XX__)
typedef unsigned char
typedef
typedef
typedef
typedef
unsigned
unsigned
unsigned
unsigned
boolean;
int
int
long int
long long int
uint8; /*This is 16 bits in C28x*/
uint16;
uint32;
uint64;
typedef unsigned int
typedef unsigned long int
uint16_least;
uint32_least;
typedef signed int
typedef signed long int
sint16_least;
sint32_least;
#else
typedef unsigned char
boolean;
typedef
typedef
typedef
typedef
unsigned
unsigned
unsigned
unsigned
uint8;
uint16;
uint32;
uint64;
typedef
typedef
typedef
typedef
signed
signed
signed
signed
char
short
int
long long int
char
short
int
long long int
sint8;
sint16;
sint32;
sint64;
typedef unsigned int
typedef unsigned int
typedef unsigned int
uint8_least;
uint16_least;
uint32_least;
typedef signed int
typedef signed int
typedef signed int
sint8_least;
sint16_least;
sint32_least;
typedef float
typedef double
float32;
float64;
#endif
C.2
Defines
#if (defined(__TMS320C28xx__) && __TI_COMPILER_VERSION__ < 6004000)
#if !defined(__GNUC__)
#error “F021 Flash API requires GCC language extensions. Use the –gcc option.”
32
Typedefs, Defines, Enumerations and Structures
Copyright © 2017, Texas Instruments Incorporated
SPNU628 – February 2017
Submit Documentation Feedback
Enumerations
www.ti.com
#endif
#endif
#ifndef TRUE
#define TRUE
#endif
1
#ifndef FALSE
#define FALSE
#endif
0
C.3
Enumerations
C.3.1
Fapi_CpuType
This is used to indicate what type of Cpu is being used.
typedef enum
{
Cpu_ARM7,
Cpu_M3,
Cpu_R4,
Cpu_R4F,
Cpu_C28,
Cpu_Undefined
} ATTRIBUTE_PACKED Fapi_CpuType;
C.3.2
Fapi_FlashProgrammingCommandsType
This contains all the possible modes used in the Fapi_IssueAsyncProgrammingCommand().
typedef enum
{
Fapi_AutoEccGeneration,
}
C.3.3
/* 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;
Fapi_FlashBankType
This is used to indicate which Flash bank is being used.
typedef enum
{
Fapi_FlashBank0,
Fapi_FlashBank1,
Fapi_FlashBank2,
Fapi_FlashBank3,
Fapi_FlashBank4,
Fapi_FlashBank5,
Fapi_FlashBank6,
Fapi_FlashBank7
} ATTRIBUTE_PACKED
SPNU628 – February 2017
Submit Documentation Feedback
/*Not used in TMS320F28004x
/*Not used in TMS320F28004x
/*Not used in TMS320F28004x
/*Not used in TMS320F28004x
/*Not used in TMS320F28004x
/*Not used in TMS320F28004x
/*Not used in TMS320F28004x
Fapi_FlashBankType;
Flash
Flash
Flash
Flash
Flash
Flash
Flash
API*/
API*/
API*/
API*/
API*/
API*/
API*/
Typedefs, Defines, Enumerations and Structures
Copyright © 2017, Texas Instruments Incorporated
33
Enumerations
C.3.4
www.ti.com
Fapi_FlashSectorType
This 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,
Fapi_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,
34
Typedefs, Defines, Enumerations and Structures
Copyright © 2017, Texas Instruments Incorporated
SPNU628 – February 2017
Submit Documentation Feedback
Enumerations
www.ti.com
}
C.3.5
Fapi_FlashSector61,
Fapi_FlashSector62,
Fapi_FlashSector63
ATTRIBUTE_PACKED Fapi_FlashSectorType;
Fapi_FlashStateCommandsType
This contains all the possible Flash State Machine commands.
typedef enum
{
Fapi_ProgramData
= 0x0002,
Fapi_EraseSector
= 0x0006,
Fapi_EraseBank
= 0x0008, /*Not available in TMS320F28004x devices */
Fapi_ValidateSector = 0x000E, /*Not available in TMS320F28004x devices */
Fapi_ClearStatus
= 0x0010,
Fapi_ProgramResume = 0x0014,
Fapi_EraseResume
= 0x0016,
Fapi_ClearMore
= 0x0018
} ATTRIBUTE_PACKED Fapi_FlashStateCommandsType;
C.3.6
Fapi_FlashReadMarginModeType
This contains all the possible Flash State Machine commands.
typedef enum
{
Fapi_NormalRead = 0x0,
Fapi_RM0
= 0x1, /*Technology used in TMS320F28004x does not need this*/
Fapi_RM1
= 0x2 /*Technology used in TMS320F28004x does not need this*/
} ATTRIBUTE_PACKED Fapi_FlashReadMarginModeType;
SPNU628 – February 2017
Submit Documentation Feedback
Typedefs, Defines, Enumerations and Structures
Copyright © 2017, Texas Instruments Incorporated
35
Enumerations
C.3.7
www.ti.com
Fapi_StatusType
This 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_Status_AsyncBusy,
/* Async function operation is Busy */
Fapi_Status_AsyncComplete,
/* Async function operation is Complete */
Fapi_Error_Fail=500,
/* Generic Function Fail code */
Fapi_Error_StateMachineTimeout, /* State machine polling never returned ready and timed out */
Fapi_Error_OtpChecksumMismatch, /* Returned if OTP checksum does not match expected value */
Fapi_Error_InvalidDelayValue,
/* Returned if the Calculated RWAIT value exceeds 15 Legacy Error */
Fapi_Error_InvalidHclkValue,
/* Returned if FClk is above max FClk value FClk is a calculated from HClk and RWAIT/EWAIT */
Fapi_Error_InvalidCpu,
/* Returned if the specified Cpu does not exist */
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,
Fapi_Error_AsyncIncorrectEccBufferLength,
Fapi_Error_AsyncDataEccBufferLengthMismatch,
Fapi_Error_FeatureNotAvailable, /* FMC feature is not available on this device */
Fapi_Error_FlashRegsNotWritable /* Returned if Flash registers are not writable due to
security */
} ATTRIBUTE_PACKED Fapi_StatusType;
C.3.8
Fapi_ApiProductionStatusType
This 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;
36
Typedefs, Defines, Enumerations and Structures
Copyright © 2017, Texas Instruments Incorporated
SPNU628 – February 2017
Submit Documentation Feedback
Structures
www.ti.com
C.4
C.4.1
Structures
Fapi_FlashStatusWordType
This structure is used to return status values in functions that need more flexibility
typedef struct
{
uint32 au32StatusWord[4];
} ATTRIBUTE_PACKED Fapi_FlashStatusWordType;
C.4.2
Fapi_LibraryInfoType
This is the structure used to return API information
typedef struct
{
uint8 u8ApiMajorVersion;
uint8 u8ApiMinorVersion;
uint8 u8ApiRevision;
Fapi_ApiProductionStatusType oApiProductionStatus;
uint32 u32ApiBuildNumber;
uint8 u8ApiTechnologyType;
uint8 u8ApiTechnologyRevision;
uint8 u8ApiEndianness;
uint32 u32ApiCompilerVersion;
} Fapi_LibraryInfoType;
SPNU628 – February 2017
Submit Documentation Feedback
Typedefs, Defines, Enumerations and Structures
Copyright © 2017, Texas Instruments Incorporated
37
Appendix D
SPNU628 – February 2017
Parallel Signature Analysis (PSA) Algorithm
D.1
Function Details
The functions Section 3.5.3 and Section 3.5.4 make use of the Parallel Signature Analysis (PSA)
algorithm. 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 calculatePSA (uint32* pu32StartAddress,
uint32 u32Length, /* Number of 32-bit words */
uint32 u32InitialSeed)
{
uint32 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;
}
38
Parallel Signature Analysis (PSA) Algorithm
Copyright © 2017, Texas Instruments Incorporated
SPNU628 – February 2017
Submit Documentation Feedback
IMPORTANT NOTICE FOR TI DESIGN INFORMATION AND RESOURCES
Texas Instruments Incorporated (‘TI”) technical, application or other design advice, services or information, including, but not limited to,
reference designs and materials relating to evaluation modules, (collectively, “TI Resources”) are intended to assist designers who are
developing applications that incorporate TI products; by downloading, accessing or using any particular TI Resource in any way, you
(individually or, if you are acting on behalf of a company, your company) agree to use it solely for this purpose and subject to the terms of
this Notice.
TI’s provision of TI Resources does not expand or otherwise alter TI’s applicable published warranties or warranty disclaimers for TI
products, and no additional obligations or liabilities arise from TI providing such TI Resources. TI reserves the right to make corrections,
enhancements, improvements and other changes to its TI Resources.
You understand and agree that you remain responsible for using your independent analysis, evaluation and judgment in designing your
applications and that you have full and exclusive responsibility to assure the safety of your applications and compliance of your applications
(and of all TI products used in or for your applications) with all applicable regulations, laws and other applicable requirements. You
represent that, with respect to your applications, you have all the necessary expertise to create and implement safeguards that (1)
anticipate dangerous consequences of failures, (2) monitor failures and their consequences, and (3) lessen the likelihood of failures that
might cause harm and take appropriate actions. You agree that prior to using or distributing any applications that include TI products, you
will thoroughly test such applications and the functionality of such TI products as used in such applications. TI has not conducted any
testing other than that specifically described in the published documentation for a particular TI Resource.
You are authorized to use, copy and modify any individual TI Resource only in connection with the development of applications that include
the TI product(s) identified in such TI Resource. NO OTHER LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE TO
ANY OTHER TI INTELLECTUAL PROPERTY RIGHT, AND NO LICENSE TO ANY TECHNOLOGY OR INTELLECTUAL PROPERTY
RIGHT OF TI OR ANY THIRD PARTY IS GRANTED HEREIN, including but not limited to any patent right, copyright, mask work right, or
other intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information
regarding or referencing third-party products or services does not constitute a license to use such products or services, or a warranty or
endorsement thereof. Use of TI Resources 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.
TI RESOURCES ARE PROVIDED “AS IS” AND WITH ALL FAULTS. TI DISCLAIMS ALL OTHER WARRANTIES OR
REPRESENTATIONS, EXPRESS OR IMPLIED, REGARDING TI RESOURCES OR USE THEREOF, INCLUDING BUT NOT LIMITED TO
ACCURACY OR COMPLETENESS, TITLE, ANY EPIDEMIC FAILURE WARRANTY AND ANY IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL
PROPERTY RIGHTS.
TI SHALL NOT BE LIABLE FOR AND SHALL NOT DEFEND OR INDEMNIFY YOU AGAINST ANY CLAIM, INCLUDING BUT NOT
LIMITED TO ANY INFRINGEMENT CLAIM THAT RELATES TO OR IS BASED ON ANY COMBINATION OF PRODUCTS EVEN IF
DESCRIBED IN TI RESOURCES OR OTHERWISE. IN NO EVENT SHALL TI BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL,
COLLATERAL, INDIRECT, PUNITIVE, INCIDENTAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES IN CONNECTION WITH OR
ARISING OUT OF TI RESOURCES OR USE THEREOF, AND REGARDLESS OF WHETHER TI HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
You agree to fully indemnify TI and its representatives against any damages, costs, losses, and/or liabilities arising out of your noncompliance with the terms and provisions of this Notice.
This Notice applies to TI Resources. Additional terms apply to the use and purchase of certain types of materials, TI products and services.
These include; without limitation, TI’s standard terms for semiconductor products http://www.ti.com/sc/docs/stdterms.htm), evaluation
modules, and samples (http://www.ti.com/sc/docs/sampterms.htm).
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2017, Texas Instruments Incorporated
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Related manuals

Download PDF

advertisement