Flash
The AM13E2X flash driverlib is split across three header files, each serving a distinct purpose. Together they provide complete access to the non-volatile memory (NVM) system — from high-level erase/program operations, through low-level flash controller register manipulation, to flash read interface configuration.
Module |
Header |
Purpose |
API Reference |
|---|---|---|---|
Flash |
|
High-level flash erase and program operations (recommended) |
|
FlashCTL |
|
Low-level flash controller register APIs |
|
FRI |
|
Flash Read Interface — cache, data line buffer, ECC, and wait state configuration |
flashapi — Flash (Recommended)
The Flash module is the recommended high-level interface for flash erase and program operations. It wraps the FlashCTL APIs and handles address validation, semaphore acquisition/release, sector unprotection, ECC generation, and post-operation verification automatically.
When to use
For most application-level flash operations — this is the recommended starting point.
When you want a simple erase-then-program workflow without managing low-level details.
When you want automatic address validation and meaningful error codes.
When you want automatic ECC generation and post-operation verification.
When you want automatic semaphore handling for safe flash access.
Info
All Flash API signatures include a required paramsPtr parameter of type
const FLASHAPI_EraseProgramParams * for per-operation configuration (e.g., verify checks).
Usage pattern:
Declare:
FLASHAPI_EraseProgramParams flashParams;Initialize:
FLASHAPI_eraseProgramParamsSetDefault(&flashParams);Pass to APIs:
FLASHAPI_eraseBank(addr, &flashParams);
Refer to examples/driverlib/flash/flash_programming/main.c for a complete usage example.
Note
flashapi.h only supports programming the MAIN flash bank. To program the non-main flash
bank, use the lower-level dl_flashctl.h APIs directly.
dl_flashctl — Flash Controller
The FlashCTL module is the low-level interface to the NVM controller hardware registers. It exposes every command type the flash controller supports (program, erase, read-verify, blank-verify, mode-change, clear-status) and gives the caller full control over command parameters such as address, byte-enable masks, data registers, ECC overrides, and sector/bank protection.
Note
TI recommends using the higher-level flashapi.h APIs for most use cases.
Use dl_flashctl.h only when you need fine-grained control that the high-level
APIs do not provide.
Warning
Flash semaphore must be managed explicitly when using FlashCTL APIs.
The flash semaphore must be acquired before the first FlashCTL API call and released at the end of the flash code sequence.
The higher-level
flashapi.hAPIs internally acquire and release the flash semaphore on every call.FlashCTL only: When exclusively using
dl_flashctl.hAPIs, acquire the flash semaphore once at the start of the flash code sequence and release it at the end of the flash code sequence.Intermixing
flashapi.handdl_flashctl.h: Eachflashapi.hAPI call internally releases the flash semaphore upon return. When adl_flashctl.hcall follows aflashapi.hcall, the flash semaphore must be re-acquired before thedl_flashctl.hcall. This rule applies at every point in the code sequence where adl_flashctl.hcall is preceded by aflashapi.hcall.
When to use
When you need sub-word programming (e.g. 8-bit or 16-bit writes) with precise byte-enable control.
When you need to manually supply ECC codes instead of relying on hardware ECC generation.
When you need to directly manipulate sector protection before issuing commands.
When you need explicit semaphore control for flash operations.
When you need to program the NON-MAIN flash bank.
dl_fri — Flash Read Interface (FRI)
The FRI module manages the flash read interface, controlling how the CPU and DMA access flash memory. It provides APIs to configure the flash cache, data line buffer (DLB), ECC (Error Correcting Code), and read wait states. These settings directly affect flash read performance and data integrity.
Wait state recommendations
The number of flash read wait states should be configured based on the system clock (SYSCLK) frequency:
SYSCLK Frequency |
Recommended Wait States |
|---|---|
< 50 MHz |
0 |
50 MHz – 100 MHz |
1 |
100 MHz – 150 MHz |
2 |
150 MHz – 200 MHz |
3 |
200 MHz – 250 MHz |
4 |
Note
DL_FRI_setReadWaitStates() is declared with the RAMFUNC attribute, meaning it executes
from RAM. This is required because changing flash wait states while executing from flash
could cause unpredictable behavior.
When to use
After changing the system clock frequency to update flash read wait states accordingly.
To enable or disable flash cache for performance tuning or debugging.
To enable or disable the data line buffer for DMA flash read optimization.
To configure flash ECC for data integrity checking.
Choosing the right module
Use case |
Flash |
FlashCTL |
FRI |
|---|---|---|---|
Simple erase + program with error checking |
✅ |
||
Sub-word programming (8/16-bit) |
✅ |
||
Manual ECC code injection (write path) |
✅ |
||
Non-blocking flash operations with interrupt |
✅ |
||
Fine-grained sector protection control |
✅ |
||
Semaphore management |
✅ (automatic) |
✅ |
|
Configure flash read wait states |
✅ |
||
Enable/disable flash cache or data line buffer |
✅ |
||
Configure flash ECC (read path) |
✅ |
EEPROM Emulation
The EEPROM emulation library provides a software-based EEPROM storage solution on internal flash memory. This is useful for applications that require persistent storage of configuration or state data across power cycles on devices without dedicated EEPROM hardware.
Key capabilities
Virtual address-based variable storage
Automatic page management and wear leveling
CRC data integrity verification
Integrated with TI driverlib FLASH and CRC APIs
References
Library:
source/libraries/eeprom_emulation/Example:
examples/driverlib/flash/flash_eeprom_emulation/Configuration:
ti_sdk_config/{device}/default/libraries_cfg/eeprom_emul_conf.h
Note
EE_CleanUp_IT() (interrupt-based cleanup) is not supported — use EE_CleanUp() instead.