EMIF Module¶
The external memory interface (EMIF) API provides a set of functions to configure device’s EMIF module. The driver provides functions to initialize the module, configure external memory parameters, obtain status information and to manage interrupts. APIs for both asynchronous and synchronous modes are supported.
-
group
emif_api
Defines
-
EMIF_ACCPROT0_FETCHPROT
MEMCFG_EMIF1ACCPROT0_FETCHPROT_EMIF1¶ This flag is used to specify whether CPU fetches are allowed/blocked for EMIF.
-
EMIF_ACCPROT0_CPUWRPROT
MEMCFG_EMIF1ACCPROT0_CPUWRPROT_EMIF1¶ This flag is used to specify whether CPU writes are allowed/blocked for EMIF.
-
EMIF_ACCPROT0_DMAWRPROT
MEMCFG_EMIF1ACCPROT0_DMAWRPROT_EMIF1¶ This flag is used to specify whether DMA writes are allowed/blocked for EMIF. It is valid only for EMIF1 instance.
-
EMIF_ACCPROT0_MASK_EMIF1
((uint16_t)MEMCFG_EMIF1ACCPROT0_FETCHPROT_EMIF1|\
(uint16_t)
MEMCFG_EMIF1ACCPROT0_CPUWRPROT_EMIF1|\
(uint16_t)
MEMCFG_EMIF1ACCPROT0_DMAWRPROT_EMIF1)¶
-
EMIF_ACCPROT0_MASK_EMIF2
((uint16_t)MEMCFG_EMIF2ACCPROT0_FETCHPROT_EMIF2|\
(uint16_t)
MEMCFG_EMIF2ACCPROT0_CPUWRPROT_EMIF2)¶
-
EMIF_ASYNC_CS_CR_MASK
((uint32_t)EMIF_ASYNC_CS2_CR_R_HOLD_M| \
(uint32_t)
EMIF_ASYNC_CS2_CR_R_STROBE_M| \
(uint32_t)
EMIF_ASYNC_CS2_CR_R_SETUP_M| \
(uint32_t)
EMIF_ASYNC_CS2_CR_W_HOLD_M| \
(uint32_t)
EMIF_ASYNC_CS2_CR_W_STROBE_M| \
(uint32_t)
EMIF_ASYNC_CS2_CR_W_SETUP_M| \
(uint32_t)
EMIF_ASYNC_CS2_CR_TA_M)¶
-
EMIF_ASYNC_INT_MASK
((uint16_t)EMIF_INT_MSK_SET_AT_MASK_SET| \
(uint16_t)
EMIF_INT_MSK_SET_LT_MASK_SET| \
(uint16_t)
EMIF_INT_MSK_SET_WR_MASK_SET_M)¶
-
EMIF_ASYNC_INT_AT
EMIF_INT_MSK_SET_AT_MASK_SET¶ This flag is used to allow/block EMIF to generate Masked Asynchronous Timeout interrupt.
-
EMIF_ASYNC_INT_LT
EMIF_INT_MSK_SET_LT_MASK_SET¶ This flag is used to allow/block EMIF to generate Masked Line Trap interrupt.
-
EMIF_ASYNC_INT_WR
EMIF_INT_MSK_SET_WR_MASK_SET_M¶ This flag is used to allow/block EMIF to generate Masked Wait Rise interrupt.
-
EMIF_MSEL_KEY
0x93A5CE70U¶
-
EMIF_SYNC_SDRAM_CR_MASK
((uint32_t)EMIF_SDRAM_CR_PAGESIGE_M| \
(uint32_t)
EMIF_SDRAM_CR_IBANK_M| \
(uint32_t)
EMIF_SDRAM_CR_BIT_11_9_LOCK| \
(uint32_t)
EMIF_SDRAM_CR_CL_M| \
(uint32_t)
EMIF_SDRAM_CR_NM| \
(uint32_t)
EMIF_SDRAM_CR_SR)¶
-
EMIF_SYNC_SDRAM_TR_MASK
((uint32_t)EMIF_SDRAM_TR_T_RRD_M| \
(uint32_t)
EMIF_SDRAM_TR_T_RC_M| \
(uint32_t)
EMIF_SDRAM_TR_T_RAS_M| \
(uint32_t)
EMIF_SDRAM_TR_T_WR_M| \
(uint32_t)
EMIF_SDRAM_TR_T_RCD_M| \
(uint32_t)
EMIF_SDRAM_TR_T_RP_M| \
(uint32_t)
EMIF_SDRAM_TR_T_RFC_M)¶
Enums
-
enum
EMIF_AsyncCSOffset
¶ Values that can be passed to EMIF_setAsyncMode(), EMIF_setAsyncTimingParams(), EMIF_setAsyncDataBusWidth(), EMIF_enableAsyncExtendedWait() and EMIF_disableAsyncExtendedWait() as the offset parameter. Three chip selects are available in asynchronous memory interface so there are three configuration registers available for each EMIF instance. All the three chip select offsets are valid for EMIF1 while only EMIF_ASYNC_CS2_OFFSET is valid for EMIF2.
Values:
-
enumerator
EMIF_ASYNC_CS2_OFFSET
= 0x8U¶ Async chip select 2 offset.
-
enumerator
EMIF_ASYNC_CS3_OFFSET
= 0xAU¶ Async chip select 3 offset.
-
enumerator
EMIF_ASYNC_CS4_OFFSET
= 0xCU¶ Async chip select 4 offset.
-
enumerator
-
enum
EMIF_AsyncDataWidth
¶ Values that can be passed to EMIF_setAsyncDataBusWidth() as the width parameter.
Values:
-
enumerator
EMIF_ASYNC_DATA_WIDTH_8
= 0x0000U¶ ASRAM/FLASH with 8 bit data bus.
-
enumerator
EMIF_ASYNC_DATA_WIDTH_16
= 0x0001U¶ ASRAM/FLASH with 16 bit data bus.
-
enumerator
EMIF_ASYNC_DATA_WIDTH_32
= 0x0002U¶ ASRAM/FLASH with 32 bit data bus.
-
enumerator
-
enum
EMIF_AsyncMode
¶ Values that can be passed to EMIF_setAsyncMode() as the mode parameter.
Values:
-
enumerator
EMIF_ASYNC_STROBE_MODE
= 0x80000000U¶ Enables ASRAM/FLASH strobe mode.
-
enumerator
EMIF_ASYNC_NORMAL_MODE
= 0x00000000U¶ Disables ASRAM/FLASH strobe mode.
-
enumerator
-
enum
EMIF_AsyncWaitPolarity
¶ Values that can be passed to EMIF_setAsyncWaitPolarity() as the polarity parameter.
Values:
-
enumerator
EMIF_ASYNC_WAIT_POLARITY_LOW
= 0x00000000U¶ EMxWAIT pin polarity is low.
-
enumerator
EMIF_ASYNC_WAIT_POLARITY_HIGH
= 0x10000000U¶ EMxWAIT pin polarity is high.
-
enumerator
-
enum
EMIF_SyncNarrowMode
¶ Values that can be passed to EMIF_setSyncMemoryConfig() as the config parameter member.
Values:
-
enumerator
EMIF_SYNC_NARROW_MODE_TRUE
= 0x00004000U¶ MemBusWidth=SystemBusWidth/2.
-
enumerator
EMIF_SYNC_NARROW_MODE_FALSE
= 0x00000000U¶ MemBusWidth=SystemBusWidth.
-
enumerator
-
enum
EMIF_SyncBank
¶ Values that can be passed to EMIF_setSyncMemoryConfig() as the config parameter member.
Values:
-
enumerator
EMIF_SYNC_BANK_1
= 0x00000000U¶ 1 Bank SDRAM device
-
enumerator
EMIF_SYNC_BANK_2
= 0x00000010U¶ 2 Bank SDRAM device
-
enumerator
EMIF_SYNC_BANK_4
= 0x00000020U¶ 4 Bank SDRAM device
-
enumerator
-
enum
EMIF_SyncCASLatency
¶ Values that can be passed to EMIF_setSyncMemoryConfig() as the config parameter member.
Values:
-
enumerator
EMIF_SYNC_CAS_LAT_2
= 0x00000500U¶ SDRAM with CAS Latency 2.
-
enumerator
EMIF_SYNC_CAS_LAT_3
= 0x00000700U¶ SDRAM with CAS Latency 3.
-
enumerator
-
enum
EMIF_SyncPageSize
¶ Values that can be passed to EMIF_setSyncMemoryConfig() as the config parameter member.
Values:
-
enumerator
EMIF_SYNC_COLUMN_WIDTH_8
= 0x00000000U¶ 256-word pages in SDRAM
-
enumerator
EMIF_SYNC_COLUMN_WIDTH_9
= 0x00000001U¶ 512-word pages in SDRAM
-
enumerator
EMIF_SYNC_COLUMN_WIDTH_10
= 0x00000002U¶ 1024-word pages in SDRAM
-
enumerator
EMIF_SYNC_COLUMN_WIDTH_11
= 0x00000003U¶ 2048-word pages in SDRAM
-
enumerator
Functions
-
void
EMIF_setAccessProtection
(uint32_t configBase, uint16_t access)¶ Sets the access protection.
This function sets the access protection for an EMIF instance from CPU and DMA. The
access parameter can be any of EMIF_ACCPROT0_FETCHPROT, EMIF_ACCPROT0_CPUWRPROT EMIF_ACCPROT0_DMAWRPROT values or their combination. EMIF_ACCPROT0_DMAWRPROT value is valid as access parameter for EMIF1 instance only .- Parameters
configBase
: is the configuration address of the EMIF instance used.access
: is the required access protection configuration.
- Return
None.
-
void
EMIF_commitAccessConfig
(uint32_t configBase)¶ Commits the lock configuration.
This function commits the access protection for an EMIF instance from CPU & DMA.
- Parameters
configBase
: is the configuration address of the EMIF instance used.
- Return
None.
-
void
EMIF_lockAccessConfig
(uint32_t configBase)¶ Locks the write to access configuration fields.
This function locks the write to access configuration fields i.e ACCPROT0 & Mselect fields, for an EMIF instance.
- Parameters
configBase
: is the configuration address of the EMIF instance used.
- Return
None.
-
void
EMIF_unlockAccessConfig
(uint32_t configBase)¶ Unlocks the write to access configuration fields.
This function unlocks the write to access configuration fields such as ACCPROT0 & Mselect fields, for an EMIF instance.
- Parameters
configBase
: is the configuration address of the EMIF instance used.
- Return
None.
-
void
EMIF_setAsyncMode
(uint32_t base, EMIF_AsyncCSOffset offset, EMIF_AsyncMode mode)¶ Selects the asynchronous mode of operation.
This function sets the mode of operation for asynchronous memory between Normal or Strobe mode. Valid values for param
offset can be EMIF_ASYNC_CS2_OFFSET, EMIF_ASYNC_CS3_OFFSET & EMIF_ASYNC_C43_OFFSET for EMIF1 and EMIF_ASYNC_CS2_OFFSET for EMIF2. Valid values for param mode can be EMIF_ASYNC_STROBE_MODE or EMIF_ASYNC_NORMAL_MODE.- Parameters
base
: is the base address of the EMIF instance used.offset
: is the offset of asynchronous chip select of EMIF instance.mode
: is the desired mode of operation for external memory.
- Return
None.
-
void
EMIF_enableAsyncExtendedWait
(uint32_t base, EMIF_AsyncCSOffset offset)¶ Enables the Extended Wait Mode.
This function enables the extended wait mode for an asynchronous external memory.Valid values for param
offset can be EMIF_ASYNC_CS2_OFFSET, EMIF_ASYNC_CS3_OFFSET & EMIF_ASYNC_C43_OFFSET for EMIF1 and EMIF_ASYNC_CS2_OFFSET for EMIF2.- Parameters
base
: is the base address of the EMIF instance used.offset
: is the offset of asynchronous chip select of the EMIF instance
- Return
None.
-
void
EMIF_disableAsyncExtendedWait
(uint32_t base, EMIF_AsyncCSOffset offset)¶ Disables the Extended Wait Mode.
This function disables the extended wait mode for an asynchronous external memory.Valid values for param
offset can be EMIF_ASYNC_CS2_OFFSET, EMIF_ASYNC_CS3_OFFSET & EMIF_ASYNC_C43_OFFSET for EMIF1 and EMIF_ASYNC_CS2_OFFSET for EMIF2.- Parameters
base
: is the base address of the EMIF instance used.offset
: is the offset of asynchronous chip select of EMIF instance.
- Return
None.
-
void
EMIF_setAsyncWaitPolarity
(uint32_t base, EMIF_AsyncWaitPolarity polarity)¶ Sets the wait polarity.
This function sets the wait polarity for an asynchronous external memory. Valid values for param
polarity can be EMIF_ASYNC_WAIT_POLARITY_LOW or EMIF_ASYNC_WAIT_POLARITY_HIGH.- Parameters
base
: is the base address of the EMIF instance used.polarity
: is desired wait polarity.
- Return
None.
-
void
EMIF_setAsyncMaximumWaitCycles
(uint32_t base, uint16_t value)¶ Sets the Maximum Wait Cycles.
This function sets the maximum wait cycles for extended asynchronous cycle. Valid values for parameter
value lies b/w 0x0U-0xFFU or 0-255.- Parameters
base
: is the base address of the EMIF instance used.value
: is the desired maximum wait cycles.
- Return
None.
-
void
EMIF_setAsyncTimingParams
(uint32_t base, EMIF_AsyncCSOffset offset, const EMIF_AsyncTimingParams *tParam)¶ Sets the Asynchronous Memory Timing Characteristics.
This function sets timing characteristics for an external asynchronous memory to be interfaced. Valid values for param
offset can be EMIF_ASYNC_CS2_OFFSET, EMIF_ASYNC_CS3_OFFSET and EMIF_ASYNC_C43_OFFSET for EMIF1 & EMIF_ASYNC_CS2_OFFSET for EMIF2.- Parameters
base
: is the base address of the EMIF instance used.offset
: is the offset of asynchronous chip select of EMIF instance.tParam
: is the desired timing parameters.
- Return
None.
-
void
EMIF_setAsyncDataBusWidth
(uint32_t base, EMIF_AsyncCSOffset offset, EMIF_AsyncDataWidth width)¶ Sets the Asynchronous Data Bus Width.
This function sets the data bus size for an external asynchronous memory to be interfaced. Valid values for param
offset can be EMIF_ASYNC_CS2_OFFSET, EMIF_ASYNC_CS3_OFFSET & EMIF_ASYNC_C43_OFFSET for EMIF1 and EMIF_ASYNC_CS2_OFFSET for EMIF2. Valid values of param width can be EMIF_ASYNC_DATA_WIDTH_8, EMIF_ASYNC_DATA_WIDTH_16 or EMIF_ASYNC_DATA_WIDTH_32.- Parameters
base
: is the base address of the EMIF instance used.offset
: is the offset of asynchronous chip select of EMIF instance.width
: is the data bus width of the memory.
- Return
None.
-
void
EMIF_enableAsyncInterrupt
(uint32_t base, uint16_t intFlags)¶ Enables the Asynchronous Memory Interrupts.
This function enables the desired interrupts for an external asynchronous memory interface. Valid values for param
intFlags can be EMIF_ASYNC_INT_AT, EMIF_ASYNC_INT_LT, EMIF_ASYNC_INT_WR or their combination.- Parameters
base
: is the base address of the EMIF instance used.intFlags
: is the mask for desired interrupts.
- Return
None.
-
void
EMIF_disableAsyncInterrupt
(uint32_t base, uint16_t intFlags)¶ Disables the Asynchronous Memory Interrupts.
This function disables the desired interrupts for an external asynchronous memory interface. Valid values for param
intFlags can be EMIF_ASYNC_INT_AT, EMIF_ASYNC_INT_LT, EMIF_ASYNC_INT_WR or their combination.- Parameters
base
: is the base address of the EMIF instance used.intFlags
: is the mask for interrupts to be disabled.
- Return
None.
-
uint16_t
EMIF_getAsyncInterruptStatus
(uint32_t base)¶ Gets the interrupt status.
This function gets the interrupt status for an EMIF instance.
- Parameters
base
: is the base address of the EMIF instance used.
- Return
Returns the current interrupt status.
-
void
EMIF_clearAsyncInterruptStatus
(uint32_t base, uint16_t intFlags)¶ Clears the interrupt status for an EMIF instance.
This function clears the interrupt status for an EMIF instance. The
intFlags parameter can be any of EMIF_INT_MSK_SET_AT_MASK_SET, EMIF_INT_MSK_SET_LT_MASK_SET, or EMIF_INT_MSK_SET_WR_MASK_SET_M values or their combination.- Parameters
base
: is the base address of the EMIF instance used.intFlags
: is the mask for the interrupt status to be cleared.
- Return
None.
-
void
EMIF_setSyncTimingParams
(uint32_t base, const EMIF_SyncTimingParams *tParam)¶ Sets the Synchronous Memory Timing Parameters.
This function sets the timing characteristics for an external synchronous memory to be interfaced.
- Parameters
base
: is the base address of an EMIF instance.tParam
: is parameters from memory datasheet in ns.
- Return
None.
-
void
EMIF_setSyncSelfRefreshExitTmng
(uint32_t base, uint16_t tXs)¶ Sets the SDRAM Self Refresh Exit Timing.
This function sets the self refresh exit timing for an external synchronous memory to be interfaced. tXs values must lie between 0x0U-0x1FU or 0-31.
- Parameters
base
: is the base address of an EMIF instance.tXs
: is the desired timing value.
- Return
None.
-
void
EMIF_setSyncRefreshRate
(uint32_t base, uint16_t refRate)¶ Sets the SDR Refresh Rate.
This function sets the refresh rate for an external synchronous memory to be interfaced. Valid values for refRate lies b/w 0x0U-0x1FFFU or 0-8191.
- Parameters
base
: is the base address of an EMIF instance.refRate
: is the refresh rate.
- Return
None.
-
void
EMIF_setSyncMemoryConfig
(uint32_t base, const EMIF_SyncConfig *config)¶ Sets the Synchronous Memory configuration parameters.
This function sets configuration parameters like CL, NM, IBANK and PAGESIZE for an external synchronous memory to be interfaced.
- Parameters
base
: is the base address of the EMIF instance used.config
: is the desired configuration parameters.
- Return
None.
-
void
EMIF_enableSyncSelfRefresh
(uint32_t base)¶ Enables Self Refresh.
This function enables Self Refresh Mode for EMIF.
- Parameters
base
: is the base address of the EMIF instance used.
- Return
None.
-
void
EMIF_disableSyncSelfRefresh
(uint32_t base)¶ Disables Self Refresh.
This function disables Self Refresh Mode for EMIF.
- Parameters
base
: is the base address of the EMIF instance used.
- Return
None.
-
void
EMIF_enableSyncPowerDown
(uint32_t base)¶ Enables Power Down.
This function Enables Power Down Mode for synchronous memory to be interfaced.
- Parameters
base
: is the base address of the EMIF instance used.
- Return
None.
-
void
EMIF_disableSyncPowerDown
(uint32_t base)¶ Disables Power Down.
This function disables Power Down Mode for synchronous memory to be interfaced.
- Parameters
base
: is the base address of the EMIF instance used.
- Return
None.
-
void
EMIF_enableSyncRefreshInPowerDown
(uint32_t base)¶ Enables Refresh in Power Down.
This function enables Refresh in Power Down Mode for synchronous memory to be interfaced.
- Parameters
base
: is the base address of the EMIF instance used.
- Return
None.
-
void
EMIF_disableSyncRefreshInPowerDown
(uint32_t base)¶ Disables Refresh in Power Down.
This function disables Refresh in Power Down Mode for synchronous memory to be interfaced.
- Parameters
base
: is the base address of the EMIF instance used.
- Return
None.
-
uint32_t
EMIF_getSyncTotalAccesses
(uint32_t base)¶ Gets total number of SDRAM accesses.
This function returns total number of SDRAM accesses from a master(CPUx/CPUx.DMA).
- Parameters
base
: is the base address of the EMIF instance used.
- Return
Returns total number of accesses to SDRAM.
-
uint32_t
EMIF_getSyncTotalActivateAccesses
(uint32_t base)¶ Gets total number of SDRAM accesses which require activate command.
This function returns total number of accesses to SDRAM which require activate command.
- Parameters
base
: is the base address of the EMIF instance used.
- Return
Returns total number of accesses to SDRAM which require activate.
-
struct
EMIF_AsyncTimingParams
¶ - #include <emif.h>
Values that can be passed to EMIF_setAsyncTimingParams() as the tParam parameter.
-
struct
EMIF_SyncConfig
¶ - #include <emif.h>
Values that can be passed to EMIF_setSyncMemoryConfig() as the config parameter.
-
struct
EMIF_SyncTimingParams
¶ - #include <emif.h>
Values that can be passed to EMIF_setSyncTimingParameters() as the tParam parameter.
-
The EMIF API include functions to set, lock/unlock, commit access configuration, set external asynchronous and synchronous memory configuration parameters and to manage asynchronous interrupts.
For interfacing asynchronous memories, functions are provided to configure EMIF registers to set mode of operation to strobe or normal mode, set enable/disable extended wait mode, set wait polarity, set maximum wait cycles, set async memory timing parameters, set memory data bus width as per the external memory to be interfaced and enable/disable, clear and get status for interrupts.
For interfacing synchronous memories, functions are provided to configure EMIF registers to set timing parameters, set self refresh exit timing, set refresh rate, set other memory specific parameters based on the external memory to be interfaced, enable/disable self refresh mode, enable/disable power down mode, enable/disable refresh in power down mode and to get total number of SDRAM accesses.
The code for this module is contained in driverlib/emif.c, with driverlib/emif.h containing the API declarations for use by applications.