NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
StarterWare EMIFA
Contents
Introduction[edit]
The EMIFA (External Memory Interface A) peripheral provides a means for the CPU to read and write external memory devices such as NAND flash, NOR flash, SDRAM, and ASRAM. By configuring bit fields in the EMIFA registers, applications can access various types of memory devices. EMIFA includes an error correction code (ECC) module that can be used to calculate the ECC for writing and reading from the NAND flash. EMIFA supports multiple ECC algorithms, including Hamming code 1 Bit and 4 Bit.
Programming[edit]
The following procedures can be used to access different devices from EMIFA using StarterWare APIs.
NAND Flash Access Via EMIFA[edit]
Basic Read/Write Access[edit]
- Set the chip select for NAND using EMIFANANDCSSet().
- Set the maximum extended wait cycles using EMIFAMaxExtWaitCycleSet().
- Select the wait pin using EMIFACSWaitPinSelect().
- Select the polarity for the wait pin using EMIFAWaitPinPolaritySet().
- Enable/Disable the interrupts using EMIFAMskedIntDisable() and EMIFAMskedIntEnable().
- Set the timing for NAND access using EMIFA_ASYNC_WAITTIME_CONFIG macro and EMIFAWaitTimingConfig().
- Select the bus width using EMIFAAsyncDevDataBusWidthSelect().
The above initialization allows applications to access NAND flash for read/write operations using commands (i.e. opcodes) appropriate for the specific NAND device.
Read/Write Access With ECC[edit]
To enable ECC for read/write operations, the following additional steps are necessary.
- Set the chip select for NAND (with ECC) using EMIFANANDCSSet().
- Initialize the ECC calculation using EMIFANANDECCStart().
- Read the calculated ECC value using EMIFANANDEccValGet().
- Load the ECC value calculated after read using EMIFANAND4BitECCLoad().
- Read the syndrome value using EMIFANANDEccValGet() for 4-bit Hamming code ECC.
- If syndrome value is non-zero, then there are ECC errors. The following steps can pin point the error location:
- Start the ECC error address calculation using EMIFANAND4BitECCAddrCalcStart().
- Run the error address calculation using EMIFANAND4BitECCStateGet().
- Read the number of ECC errors using EMIFANAND4BitECCNumOfErrsGet().
- Read the error address and error value using EMIFANAND4BitEccErrAddrGet() and EMIFANAND4BitEccErrValGet().
- Correct the error.