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

flashapi.h

High-level flash erase and program operations (recommended)

FLASH API Guide

FlashCTL

dl_flashctl.h

Low-level flash controller register APIs

FLASHCTL API Guide

FRI

dl_fri.h

Flash Read Interface — cache, data line buffer, ECC, and wait state configuration

FRI API Guide



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.h APIs internally acquire and release the flash semaphore on every call.

  • FlashCTL only: When exclusively using dl_flashctl.h APIs, 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.h and dl_flashctl.h: Each flashapi.h API call internally releases the flash semaphore upon return. When a dl_flashctl.h call follows a flashapi.h call, the flash semaphore must be re-acquired before the dl_flashctl.h call. This rule applies at every point in the code sequence where a dl_flashctl.h call is preceded by a flashapi.h call.


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

Module selection guide

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.