SPNU501
SPNU501
Version 1.00
Reference Guide
List of Figures
1 Recommended Erase Flow .............................................................................................. 37
2 Recommended Program Flow ........................................................................................... 38
List of Tables
1 API Revision History ........................................................................................................ 5
2 Document Revision History ................................................................................................ 5
3 Summary of Initialization Functions ...................................................................................... 7
4 Summary of Flash State Machine Functions ............................................................................ 7
5 Summary of Asynchronous Operation Functions ....................................................................... 7
6 Summary of Programming Functions .................................................................................... 7
7 Summary of Read Functions .............................................................................................. 7
8 Summary of Information Functions ....................................................................................... 8
9 Summary of User Defined Functions ..................................................................................... 8
10 Summary of Utility Functions .............................................................................................. 8
11 FMSTAT Register ......................................................................................................... 11
12 FMSTAT Register Field Descriptions ................................................................................... 11
13 Flash State Machine Commands ........................................................................................ 39
1 Revision History
2 Introduction
2.1 Background
This 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.
<type_n> parameter_n
)
Parameters
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
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().
3.1 Introduction
The F021 Flash API is a library of routine that when called with the proper parameters in the proper
sequence, erases, programs, or verifies Flash memory on Texas Instruments microcontrollers using the
F021 process. These routines must be run a in a privilege mode (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.
4 API Functions
4.1.1 Fapi_initializeAPI()
Initializes the Flash API
Synopsis
Fapi_StatusType Fapi_initializeAPI(
Fapi_FmcRegistersType *poFlashControlRegister,
uint32 u32HclkFrequency)
Parameters
poFlashControlRegister [in] Pointer to the Flash Memory Controller Registers base address
u32HclkFrequency [in] 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 if a different Flash Memory Controller is to be used on devices that have
multiple Flash Memory Controllers or System frequency has changed.
Return Value
• Fapi_Status_Success (success)
Sample Implementation
#include “F021.h”
#define HCLK_FREQUENCY 80 /* 80 MHz System frequency */
int main(void)
{
Fapi_StatusType oReturnCheck;
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,HCLK_FREQUENCY);
4.2.1 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 value returned is not interpreted and it is up to
the user’s code to handle the return value.
Return Value
4.2.2 Fapi_checkFsmForReady()
Returns the status of the Flash State Machine
Synopsis
Fapi_StatusType Fapi_checkFsmForReady()
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. 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)
4.2.3 Fapi_connectFlashPumpToCpu()
Connects the Flash Pump to specified CPU FMC
Synopsis
Fapi_StatusType Fapi_connectFlashPumpToCpu(
Fapi_CpuSelectorType oFlashCpu)
Parameters
Description
This is a placeholder function for future devices that will have multiple Flash Memory Controllers and only
one Flash pump.
Return Value
• Fapi_Status_Success (success)
4.2.4 Fapi_enableBanksForOtpWrite()
Enables programming of Customer OTP for specified banks
Synopsis
Fapi_StatusType Fapi_enableBanksForOtpWrite(
uint8 u8Banks)
Parameters
u8Banks [in] Bit mask indicating each bank to be enabled for OTP programming
Description
This function sets up the OTPPRODIS field in the FBAC register to enable Customer OTP programming
for the banks specified in the bitfield mask u8Banks.
Return Value
• Fapi_Status_Success (success)
4.2.5 Fapi_disableBanksForOtpWrite()
Disables programming of Customer OTP
Synopsis
Fapi_StatusType Fapi_enableBanksForOtpWrite(void)
Parameters
None
Description
This function sets OTPPRODIS field in the FBAC register to disable Customer OTP programming for all
banks.
Return Value
• Fapi_Status_Success (success)
4.2.6 Fapi_setActiveFlashBank()
Changes the active Flash Bank
Synopsis
Fapi_StatusType Fapi_setActiveFlashBank(
Fapi_FlashBankType oNewFlashBank)
Parameters
Description
This function sets the active bank for further Flash operations to be performed on that bank and sets up
the Flash Memory Controller for that bank.
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.h"
int main(void)
{
Fapi_StatusType oReturnCheck;
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
4.2.7 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 following FSM commands Program
Data, Erase Sector, and Erase Bank 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)
4.2.8 Fapi_writeEwaitValue()
Writes value to the EWAIT register location
Synopsis
Fapi_StatusType Fapi_writeEwaitValue(
uint32 u32Ewait)
Parameters
Description
This function writes the supplied EWAIT value to the EEPROM_CONFIG register in the FMC.
Return Value
• Fapi_Status_Success (success)
4.2.9 Fapi_flushPipeline()
Flushes the FMC pipeline buffers
Synopsis
void Fapi_flushPipeline(void)
Parameters
None
Description
This function flushes the FMC pipeline buffers. The pipeline must be flushed before the first non-API Flash
read after an operation that modifies the Flash contents (i.e., Erasing and Programming).
Return Value
None
4.2.10 Fapi_remapEccAddress()
Takes ECC address and remaps it to main address space
Synopsis
uint32 Fapi_remapEccAddress(
uint32 u32EccAddress)
Parameters
Description
This function returns the main Flash address for the given ECC Flash address.
Return Value
• 32-bit Main Flash Address
4.2.11 Fapi_isAddressEcc()
Indicates is an address is in the Flash Memory Controller ECC space
Synopsis
boolean Fapi_isAddressEcc(
uint32 u32Address)
Parameters
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)
4.3.1 Fapi_issueAsyncCommandWithAddress()
Issues a command to the Flash State Machine with an address
Synopsis
Fapi_StatusType Fapi_issueAsyncCommandWithAddress(
Fapi_FlashStateCommandsType oCommand,
uint32 *pu32StartAddress)
Parameters
Description
This 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.
Return Value
• Fapi_Status_Success (success)
Sample Implementation
#include “F021.h”
#define HCLK_FREQUENCY 80 /* 80 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 *) 0);
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
4.3.2 Fapi_issueAsyncCommand()
Issues a command to the Flash State Machine
Synopsis
Fapi_StatusType Fapi_issueAsyncCommand(
Fapi_FlashStateCommandsType oCommand)
Parameters
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.
Return Value
• Fapi_Status_Success (success)
Sample Implementation
#include “F021.h”
#define HCLK_FREQUENCY 80 /* 80 MHz System frequency */
int main(void)
{
Fapi_StatusType oReturnCheck;
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,HCLK_FREQUENCY);
oReturnCheck = Fapi_issueAsyncCommand(Fapi_ClearStatus);
4.4.1 Fapi_issueProgrammingCommand()
Sets up data and issues program command to valid Flash memory addresses
Synopsis
Fapi_StatusType Fapi_issueProgrammingCommand(
uint32 *pu32StartAddress,
uint8 *pu8DataBuffer,
uint8 u8DataBufferSizeInBytes,
uint8 *pu8EccBuffer,
uint8 u8EccBufferSizeInBytes,
Fapi_FlashProgrammingCommandType oMode)
Parameters
pu32StartAddress [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 bot 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 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. The ECC is calculated for the data width of the bank and data not supplied is treated as
0xFF. 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 64bit 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.
(Ex. Programming 3 bytes on a 2 byte ECC wide bank starting at address 0x0 is not allowed.)
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 64bit
aligned or Data length exceeds amount ECC supplied)
Sample Implementation
#include “F021.h”
int main(void)
{
uint8 au8DataBuffer[16] = {0x00, 0x01, 0x02, 0x03, 0x04,0x05, 0x06, 0x07,0x08, 0x09,
0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
Fapi_StatusType oReturnCheck;
uint32 u32Index;
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,80);
if(oReturnCheck == Fapi_Status_Success)
{
oReturnCheck = Fapi_setActiveFlashBank(oActiveFlashBank);
if(oReturnCheck == Fapi_Status_Success)
{
for(u32Index = 0;
(u32Index < 0x40) && (oReturnCheck == Fapi_Status_Success);
u32Index+= 0x10)
{
oReturnCheck = Fapi_issueProgrammingCommand(
(uint32 *) u32Index,
au8DataBuffer,
0x10,
0,
0,
Fapi_AutoEccGeneration);
while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
oReturnCheck = Fapi_getFsmStatus();
}
}
}
}
4.4.2 Fapi_issueProgrammingCommandForEccAddress()
Remaps an ECC address to data address and calls Fapi_issueProgrammingCommand().
Synopsis
Fapi_StatusType Fapi_issueProgrammingCommandForEccAddress(
uint32 *pu32StartAddress,
uint8 *pu8EccBuffer,
uint8 u8EccBufferSizeInBytes)
Parameters
pu32StartAddress [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
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.
Return Value
• Fapi_Status_Success (success)
• Fapi_Error_AsyncIncorrectEccBufferLength (failure: Data buffer size specified exceeds ECC bank
width)
4.5.1 Fapi_doBlankCheck()
Verifies region specified is erased value
Synopsis
Fapi_StatusType Fapi_doBlankCheck(
uint32 *pu32StartAddress,
uint32 u32Length,
Fapi_FlashStatusWordType *poFlashStatusWord)
Parameters
Description
This function checks the device for blank (erase state) starting at the specified address for the length of
32bit words specified. If a non-blank location is found, these results will be returned in the
poFlashStatusWord parameter. This will use normal read, read margin 0 and read margin 1 modes
checking for blank.
NOTE: 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)
4.5.2 Fapi_doBlankCheckByByte()
Verifies region specified is erased value by byte
Synopsis
Fapi_StatusType Fapi_doBlankCheckByByte(
uint8 *pu8StartAddress,
uint32 u32Length
Fapi_FlashStatusWordType *poFlashStatusWord)
Parameters
Description
This function checks the device for blank (erase state) starting at the specified address for the length of
8bit words specified. If a non-blank location is found, these results will be returned in the
poFlashStatusWord parameter. This will use normal read, read margin 0 and read margin 1 modes
checking for blank.
NOTE: 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)
4.5.3 Fapi_doVerify()
Verifies region specified against supplied data
Synopsis
Fapi_StatusType Fapi_doVerify(
uint32 *pu32StartAddress,
uint32 u32Length,
uint32 *pu32CheckValueBuffer,
Fapi_FlashStatusWordType *poFlashStatusWord)
Parameters
Description
This function verifies the device against the supplied data starting at the specified address for the length of
32bit 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.
NOTE: 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)
4.5.4 Fapi_doVerifyByByte()
Verifies region specified against supplied data by byte
Synopsis
Fapi_StatusType Fapi_doVerifyByByte(
uint8 *pu8StartAddress,
uint32 u32Length,
uint8 *pu8CheckValueBuffer,
Fapi_FlashStatusWordType *poFlashStatusWord)
Parameters
Description
This function verifies the device against the supplied data by byte starting at the specified address for the
length of 8bit 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.
NOTE: 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)
4.5.5 Fapi_doPsaVerify()
Verifies region specified against specified PSA value
Synopsis
Fapi_StatusType Fapi_doPsaVerify(
uint32 *pu32StartAddress,
uint32 u32Length,
uint32 u32PsaValue,
Fapi_FlashStatusWordType *poFlashStatusWord)
Parameters
Description
This function verifies the device against the supplied PSA value starting at the specified address for the
length of 32bit words specified. The calculated PSA values for all 3 margin modes are returned in the
poFlashStatusWord parameter.
NOTE: The 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)
4.5.6 Fapi_calculatePsa()
Calculates the PSA for a specified region
Synopsis
Fapi_StatusType Fapi_calculatePsa(
uint32 *pu32StartAddress,
uint32 u32Length,
uint32 u32PsaSeed
Fapi_FlashReadMarginModeType oReadMode)
Parameters
Description
This function calculates the PSA value for the region specified starting at pu32StartAddress for u32Length
32bit words using u32PsaSeed value in the margin mode specified.
NOTE: The region that the PSA is being calculated on cannot cross bank address boundary
Return Value
• Fapi_Status_Success (success)
• Fapi_Error_InvalidReadMode (failure: read mode specified is not valid)
4.5.7 Fapi_doMarginRead()
Reads a region of Flash Memory using specified margin mode
Synopsis
Fapi_StatusType Fapi_doMarginRead(
uint32 *pu32StartAddress,
uint32 *pu32ReadBuffer,
uint32 u32Length,
Fapi_FlashReadMarginModeType oReadMode)
Parameters
Description
This function reads the region specified starting at pu32StartAddress for u32Length 32bit words using
pu32ReadBuffer to store the read values.
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)
4.5.8 Fapi_doMarginReadByByte()
Reads a region of Flash Memory using specified margin mode by byte
Synopsis
Fapi_StatusType Fapi_doMarginReadByByte(
uint8 *pu8StartAddress,
uint8 *pu8ReadBuffer,
uint32 u32Length,
Fapi_FlashReadMarginModeType oReadMode)
Parameters
Description
This function reads the region specified starting at pu8StartAddress for u32Length 8bit words using
pu8ReadBuffer to store the read values.
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)
4.6.1 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
• 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
0x20
• 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
• u8ApiCompilerVersion – 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)
4.6.2 Fapi_getDeviceInfo()
Returns information about specific to device code is being executed on
Synopsis
Fapi_DeviceInfoType Fapi_getDeviceInfo(void)
Parameters
None
Description
This 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)
4.6.3 Fapi_getBankSectors()
Returns the sector information for the requested bank
Synopsis
Fapi_StatusType Fapi_getBankSectors(
Fapi_FlashBankType oBank,
Fapi_FlashBankSectorsType *poFlashBankSectors)
Parameters
Description
This function returns information about the bank starting address, number of sectors, sector sizes, 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
• au8SectorSizes[] – An array of sectors sizes for each sector in the bank
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)
4.7.1 Fapi_calculateFletcherChecksum()
Calculates the Fletcher checksum from the given address and length
Synopsis
uint32 Fapi_calculateFletcherChecksum(
uint16 *pu16Data,
uint16 u16Length)
Parameters
Description
This function generates a 32bit Fletcher checksum starting at the supplied address for the number of 16bit
words specified.
Return Value
• • 32bit Fletcher Checksum value
4.7.2 Fapi_calculateEcc()
Calculates the ECC for a 64bit value
Synopsis
uint8 Fapi_calculateEcc(
uint32 u32Address,
uint32 u32Data)
Parameters
Description
This function will calculate the ECC for a 64bit aligned word including address if device supports address
in ECC calculation.
Return Value
• 8bit calculated ECC
4.7.3 Fapi_waitDelay()
Generates a delay for amount specified
Synopsis
uint8 Fapi_calculateEcc(
uint32 u32WaitDelay)
Parameters
Description
This function will generate a wait for the number of us increments.
Return Value
• Fapi_Status_Success (success)
4.8.1 Fapi_serviceWatchdogTimer()
Services the watchdog timer
Synopsis
Fapi_StatusType Fapi_serviceWatchdogTimer(void)
Parameters
None
Description
This function allows the user to service their watchdog timer.
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);
}
4.8.2 Fapi_setupEepromSectorEnable()
Sets up the sectors available on EEPROM bank for erase and programming
Synopsis
Fapi_StatusType Fapi_setupEepromSectorEnable(void)
Parameters
None
Description
This function sets up the sectors in the EEPROM bank that are available for erase and programming
operations.
Return Value
• Fapi_Status_Success (success)
Sample Implementation
#include “F021.h”
Fapi_StatusType Fapi_setupEepromSectorEnable(void)
{
/* Value must be 0xFFFF to enable erase and programming of the EEPROM bank, 0 to disable */
Fapi_GlobalInit.m_poFlashControlRegisters->Fbse.u32Register = 0xFFFF;
/* Enables/disables sectors 0-31 for bank and sector erase */
Fapi_GlobalInit.m_poFlashControlRegisters->FsmSector1.u32Register = 0;
/* Enables/disables sectors 32-63 for bank and sector erase */
Fapi_GlobalInit.m_poFlashControlRegisters->FsmSector2.u32Register = 0;
return(Fapi_Status_Success);
}
4.8.3 Fapi_setupBankSectorEnable()
Sets up the sectors available on non EEPROM banks for erase and programming
Synopsis
Fapi_StatusType Fapi_setupBankSectorEnable(void)
Parameters
None
Description
This function sets up the sectors in the non EEPROM banks that are available for erase and programming
operations.
Return Value
• Fapi_Status_Success (success)
Sample Implementation
#include “F021.h”
Fapi_StatusType Fapi_setupEepromSectorEnable(void)
{
/* Enables/disables sectors 0-15 for bank and sector erase */
Fapi_GlobalInit.m_poFlashControlRegisters
->FsmSector.FSM_SECTOR_BITS.SECT_ERASED = 0;
/* Enable sectors 0-15 for erase and programming */
Fapi_GlobalInit.m_poFlashControlRegisters->Fbse.u32Register = 0xFFFF;
Start
Call
Fapi_setActiveFlashBank()
for current bank
Call
Fapi_issueAsyncCommandWithAddress()
Using either Fapi_EraseBank command
or Fapi_EraseSector command
Execute other
code as
needed
No
Fapi_checkFsmForReady()
! = Fapi_Status_FsmBusy
Yes
No
Fapi_getFsmStatus() DUT fails Erase
!=0
Yes
Yes
Another Sector/Bank to
Erase?
No
Done
Start
Call
Fapi_setActiveFlashBank()
for current bank
Call Fapi_issueProgrammingCommand()
Supplying address, data and mode
Execute other
code as
needed
No
Fapi_checkFsmForReady()
! = Fapi_Status_FsmBusy
Yes
No
Fapi_getFsmStatus() DUT fails Program
!=0
Yes
Yes
More data to program?
No
Done
B.2 Defines
#define false FALSE;
#define true TRUE;
B.3 Enumerations
B.3.1 Fapi_CpuSelectorType
This is used to indicate which CPU is being used.
typedef enum
{
Fapi_MasterCpu,
Fapi_SlaveCpu0
} Fapi_CpuSelectorType;
B.3.2 Fapi_CpuType
This is used to indicate what type of Cpu is being used.
typedef enum
{
ARM7,
M3,
R4,
R4F,
C28,
Undefined
} Fapi_CpuType;
B.3.3 Fapi_FamilyType
This 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
} Fapi_FamilyType;
B.3.4 Fapi_AddressMemoryType
This is used to indicate what type of Address is being used.
typedef enum
{
Fapi_Flash,
Fapi_FlashEcc,
Fapi_Otp,
Fapi_OtpEcc,
Fapi_Undefined
} Fapi_AddressMemoryType;
B.3.5 Fapi_FlashProgrammingCommandsType
This 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 */
} Fapi_FlashProgrammingCommandsType;
B.3.6 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
} Fapi_FlashBankType;
B.3.7 Fapi_FlashBankTechType
This is used to indicate what F021 Bank Technology the bank is
typedef enum
{
Fapi_FLEP,
Fapi_FLEE,
Fapi_FLES,
Fapi_FLHV,
Fapi_TechTBD
} Fapi_FlashBankTechType;
B.3.8 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,
Fapi_FlashSector61,
Fapi_FlashSector62,
Fapi_FlashSector63
} Fapi_FlashSectorType;
B.3.9 Fapi_FlashStateCommandsType
This 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
} Fapi_FlashStateCommandsType;
B.3.10 Fapi_FlashReadMarginModeType
This contains all the possible Flash State Machine commands.
typedef enum
{
Fapi_NormalRead = 0x0,
Fapi_RM0 = 0x1,
Fapi_RM1 = 0x2
} Fapi_FlashReadMarginModeType;
B.3.11 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_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_StatusType;
B.3.12 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 */
} Fapi_ApiProductionStatusType;
B.4 Structures
B.4.1 Fapi_EngineeringRowType
This is used to return the information from the engineering row in the TI OTP.
typedef struct
{
uint32 u32AsicId;
uint8 u8Revision;
uint32 u32LotNumber;
uint16 u16FlowCheck;
uint16 u16WaferNumber;
uint16 u16XCoordinate;
uint16 u16YCoordinate;
} Fapi_EngineeringRowType;
B.4.2 Fapi_FlashStatusWordType
This structure is used to return status values in functions that need more flexibility
typedef struct
{
uint32 au32StatusWord[4];
} Fapi_FlashStatusWordType;
B.4.3 Fapi_TiOtpBytesType
This is used to define an accessor to the TI OTP values
#if defined(_LITTLE_ENDIAN)
typedef volatile union
{
struct
{
uint32 ChecksumLength:16; /* 0x150 bits 15:0 */
uint32 OtpVersion:16; /* 0x150 bits 31:16 */
uint32 OtpChecksum; /* 0x154 bits 31:0 */
uint32 NumberOfBanks:16; /* 0x158 bits 15:0 */
uint32 NumberOfSectors:16; /* 0x158 bits 31:16 */
uint32 MemorySize:16; /* 0x15C bits 15:0 */
uint32 Package:16; /* 0x15C bits 31:16 */
uint32 SiliconRevision:8; /* 0x160 bits 7:0 */
uint32 AsicNumber:24; /* 0x160 bits 31:8 */
uint32 LotNumber; /* 0x164 bits 31:0 */
uint32 WaferNumber:16; /* 0x168 bits 15:0 */
uint32 Flowbits:16; /* 0x168 bits 31:16 */
uint32 YCoordinate:16; /* 0x16C bits 15:0 */
uint32 XCoordinate:16; /* 0x16C bits 31:16 */
uint32 EVSU:8; /* 0x170 bits 7:0 */
uint32 PVSU:8; /* 0x170 bits 15:8 */
uint32 ESU:8; /* 0x170 bits 23:16 */
uint32 PSU:8; /* 0x170 bits 31:24 */
uint32 CVSU:12; /* 0x174 bits 11:0 */
uint32 Add_EXEZSU:4; /* 0x174 bits 15:12 */
uint32 PVAcc:8; /* 0x174 bits 23:16 */
uint32 RVSU:8; /* 0x174 bits 31:24 */
uint32 PVH2:8; /* 0x178 bits 7:0 */
uint32 PVH:8; /* 0x178 bits 15:8 */
uint32 RH:8; /* 0x178 bits 23:16 */
uint32 PH:8; /* 0x178 bits 31:24 */
uint32 SmFrequency:12; /* 0x17C bits 11:0 */
uint32 VSTAT:4; /* 0x17C bits 15:12 */
uint32 Sequence:8; /* 0x17C bits 23:16 */
uint32 EH:8; /* 0x17C bits 31:24 */
uint32 VHV_EStep:16; /* 0x180 bits 15:0 */
uint32 VHV_EStart:16; /* 0x180 bits 31:16 */
uint32 MAX_PP:16; /* 0x184 bits 15:0 */
uint32 OtpReserved1:16; /* 0x184 bits 31:16 */
uint32 PROG_PW:16; /* 0x188 bits 15:0 */
uint32 MAX_EP:16; /* 0x188 bits 31:16 */
uint32 ERA_PW; /* 0x18C bits 31:0 */
uint32 VHV_E:16; /* 0x190 bits 15:0 */
uint32 VHV_P:16; /* 0x190 bits 31:16 */
uint32 VINH:8; /* 0x194 bits 7:0 */
uint32 VCG:8; /* 0x194 bits 15:8 */
uint32 VHV_PV:16; /* 0x194 bits 31:16 */
uint32 OtpReserved2:8; /* 0x198 bits 7:0 */
uint32 VRead:8; /* 0x198 bits 15:8 */
uint32 VWL_P:8; /* 0x198 bits 23:16 */
uint32 VSL_P:8; /* 0x198 bits 31:24 */
uint32 ApiChecksum:32; /* 0x19C bits 31:0 */
uint32 OtpReserved3:32; /* 0x1A0 bits 31:0 */
uint32 OtpReserved4:32; /* 0x1A4 bits 31:0 */
uint32 OtpReserved5:32; /* 0x1A8 bits 31:0 */
uint32 OtpReserved6:32; /* 0x1AC bits 31:0 */
} OTP_VALUE;
uint8 au8OtpWord[0x60];
uint16 au16OtpWord[0x30];
uint32 au32OtpWord[0x18];
}Fapi_TiOtpBytesType;
#else
typedef volatile union
{
struct
{
uint32 OtpVersion:16; /* 0x150 bits 31:16 */
uint32 ChecksumLength:16; /* 0x150 bits 15:0 */
uint32 OtpChecksum; /* 0x154 bits 31:0 */
uint32 NumberOfSectors:16; /* 0x158 bits 31:16 */
B.4.4 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;
B.4.5 Fapi_DeviceInfoType
This is the structure used to return device information
typedef struct
{
uint16 u16Reserved;
uint16 u16NumberOfBanks;
uint16 u16DevicePackage;
uint16 u16DeviceMemorySize;
uint32 u32AsicId;
uint32 u32LotNumber;
uint16 u16FlowCheck;
uint16 u16WaferNumber;
uint16 u16WaferXCoordinate;
uint16 u16WaferYCoordinate;
}Fapi_DeviceInfoType;
B.4.6 Fapi_FlashBankSectorsType
This gives the structure of a bank and technology type
typedef struct
{
Fapi_FlashBankTechType oFlashBankTech;
uint32 u32NumberOfSectors;
uint32 u32BankStartAddress;
uint8 au8SectorSizes[16];
}Fapi_FlashBankSectorsType;
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2011, Texas Instruments Incorporated