NHS31xx SW API
flash: Flash driver

Detailed Description

The Flash driver provides APIs to select the power mode that the flash memory operates in, and the number of wait states to apply to flash operations.

Note
Please note that this API provides only a small part of the features.
Flash Power Modes
The flash memory on the chip supports two power modes:
  • low power mode
  • high power mode
    High power mode may be required for some flash operations, please refer to the user manual for details.
Warning
Directly accessing Flash controller addresses (NSS_FLASH_T) when the Flash clock is disabled blocks the APB bus indefinitely.
Wait States
To manage the flash memory read operation in low power mode, it may be necessary - dependent on the the system clock frequency - to wait for some number of extra system clocks, which is also called wait states. Please refer to the user manual for more details. For a full list of clock restrictions in effect, see SW Clock Restrictions.
Erasing/Writing
For flash erasing and writing, please refer to iap: In Application Programming driver.
Example - Switching between flash modes:
Assume a controller that normally runs at 0.5MHz, but it can also run at 8MHz. When running on 8MHz, the flash should be either in high power mode(1), or in low power mode with extra wait states(2).
  1. Switch to 8MHz in low power mode with extra wait states
  2. Switch to 8MHz in high power mode without extra wait states

Data Structures

struct  NSS_FLASH_T
 

Functions

void Chip_Flash_SetHighPowerMode (bool highPower)
 
bool Chip_Flash_GetHighPowerMode (void)
 
void Chip_Flash_SetNumWaitStates (int waitStates)
 
int Chip_Flash_GetNumWaitStates (void)
 

Data Structure Documentation

◆ NSS_FLASH_T

struct NSS_FLASH_T

NSS Flash register block structure

Data Fields
__IO uint32_t FCTR

Flash control register

__I uint32_t FSTAT

Flash status register

__IO uint32_t FPTR

Flash program-time register

__I uint32_t RESERVED1
__IO uint32_t FBWST

Flash wait state register

__I uint32_t RESERVED2[2]
__IO uint32_t FCRA

Flash program clock divider

__IO uint32_t FMSSTART

Flash checksum start address register

__IO uint32_t FMSSTOP

Flash checksum stop address register

__I uint32_t FMS16

Flash parity signature register

__I uint32_t FMSW0

Flash data signature register

__I uint32_t RESERVED3[8]
__IO uint32_t ECCRSTERRCNT

Invalid flag and error corrected counter reset

__I uint32_t ECCERRCNT

ECC status information

__I uint32_t RESERVED4[990]
__I uint32_t MODULE_CONFIG

Controller configuration options

__I uint32_t RESERVED5
__O uint32_t INT_CLR_ENABLE

Clear interrupt enable bits

__O uint32_t INT_SET_ENABLE

Set interrupt enable bits

__I uint32_t INT_STATUS

Interrupt status bits

__I uint32_t INT_ENABLE

Interrupt enable bits

__O uint32_t INT_CLR_STATUS

Clear interrupt status bits

__O uint32_t INT_SET_STATUS

Set interrupt status bits

__I uint32_t RESERVED6[3]
__I uint32_t MODULE_ID

Controller memory module identification

Function Documentation

◆ Chip_Flash_SetHighPowerMode()

void Chip_Flash_SetHighPowerMode ( bool  highPower)

Sets the power mode of the flash memory.

Parameters
highPower: True for high power mode, false for low power mode
Precondition
If highPower equals false, the caller must ensure that either
  • flash wait states is set to 1 or higher, or
  • system clock divisor is not 1 - by calling Chip_Clock_System_SetClockFreq with argument 4000000 or less.
Failure to do so will result in a hard fault (flash access error). See also SW Clock Restrictions

◆ Chip_Flash_GetHighPowerMode()

bool Chip_Flash_GetHighPowerMode ( void  )

Gets the power mode of the flash memory.

Returns
True if the flash memory operates in high power mode, false otherwise.

◆ Chip_Flash_SetNumWaitStates()

void Chip_Flash_SetNumWaitStates ( int  waitStates)

Sets the number of wait states for flash operations.

Parameters
waitStates: Number of wait states to be added to flash operations.
Precondition
If waitStates equals 0, the caller must ensure that either Failure to do so will result in a hard fault (flash access error). See also SW Clock Restrictions

◆ Chip_Flash_GetNumWaitStates()

int Chip_Flash_GetNumWaitStates ( void  )

Gets the number of wait states applied to flasAh operations.

Returns
The number of wait states that are currently applied to flash operations.