|
void | XMC_FLASH_ClearStatus (void) |
|
void | XMC_FLASH_DisableEvent (const uint32_t event_msk) |
|
void | XMC_FLASH_EnableEvent (const uint32_t event_msk) |
|
void | XMC_FLASH_EnterSleepMode (void) |
|
int32_t | XMC_FLASH_ErasePage (uint32_t *address) |
|
int32_t | XMC_FLASH_ErasePages (uint32_t *address, uint32_t num_pages) |
|
int32_t | XMC_FLASH_EraseSector (uint32_t *address) |
|
void | XMC_FLASH_ExitSleepMode (void) |
|
uint32_t | XMC_FLASH_GetSectorAddress (uint32_t sector) |
|
uint32_t | XMC_FLASH_GetStatus (void) |
|
bool | XMC_FLASH_IsBusy (void) |
|
int32_t | XMC_FLASH_ProgramPage (uint32_t *address, const uint32_t *data) |
|
int32_t | XMC_FLASH_ProgramVerifyPage (uint32_t *address, const uint32_t *data) |
|
void | XMC_FLASH_ReadBlocks (uint32_t *address, uint32_t *data, uint32_t num_blocks) |
|
uint32_t | XMC_FLASH_ReadWord (const uint32_t *const address) |
|
void | XMC_FLASH_SetHardReadLevel (XMC_FLASH_HARDREAD_LEVEL_t level) |
|
void | XMC_FLASH_SetSectorProtection (uint32_t num_sectors) |
|
void | XMC_FLASH_VerifyBlocks (uint32_t *address, const uint32_t *data, uint32_t num_blocks) |
|
void | XMC_FLASH_WriteBlocks (uint32_t *address, const uint32_t *data, uint32_t num_blocks, bool verify) |
|
Flash is a non volatile memory module used to store instruction code or constant data. The flash low level driver provides support to the following functionalities of flash memory.
-
Provides functions to program and verify pages. ( XMC_FLASH_ProgramPage(), XMC_FLASH_ProgramPages() XMC_FLASH_ProgramVerifyPage() )
-
Provides functions to write and verify blocks. ( XMC_FLASH_WriteBlocks(), XMC_FLASH_VerifyBlocks() )
-
Provides functions to read data in terms of word and blocks. ( XMC_FLASH_ReadBlocks(), XMC_FLASH_ReadWord() )
-
Provides function to erase page. ( XMC_FLASH_ErasePage() )
◆ XMC_FLASH_BASE
#define XMC_FLASH_BASE (0x10001000U) |
Starting address of flash for XMC1 family of microcontrollers
◆ XMC_FLASH_BLOCKS_PER_PAGE
#define XMC_FLASH_BLOCKS_PER_PAGE (16U) |
Number of blocks in a page. A block consists of 4 words(16 bytes).
◆ XMC_FLASH_BYTES_PER_BLOCK
#define XMC_FLASH_BYTES_PER_BLOCK (16U) |
Number of bytes in a block. (128 bits = 16 bytes)
◆ XMC_FLASH_BYTES_PER_PAGE
#define XMC_FLASH_BYTES_PER_PAGE (256U) |
Number of bytes in a page. (16 blocks * 16 bytes = 256 bytes)
◆ XMC_FLASH_BYTES_PER_SECTOR
#define XMC_FLASH_BYTES_PER_SECTOR (4096U) |
Number of bytes in a sector. (16 pages * 256 bytes = 4096 bytes)
◆ XMC_FLASH_PAGES_PER_SECTOR
#define XMC_FLASH_PAGES_PER_SECTOR (16U) |
Number of pages in a sector. A page consists of 16 blocks.
◆ XMC_FLASH_WORDS_PER_BLOCK
#define XMC_FLASH_WORDS_PER_BLOCK (4U) |
Number of words in a block. (128 bit / 32 bit = 4 words)
◆ XMC_FLASH_WORDS_PER_PAGE
#define XMC_FLASH_WORDS_PER_PAGE (64U) |
Number of words in a page. (16 blocks * 4 words = 64 words)
◆ XMC_FLASH_WORDS_PER_SECTOR
#define XMC_FLASH_WORDS_PER_SECTOR (1024U) |
Number of words in a sector. (16 pages * 64 words = 1024 words)
◆ XMC_FLASH_EVENT_t
Defines NVM ready interrupt event. Use type XMC_FLASH_EVENT_t for this enum.
Enumerator |
---|
XMC_FLASH_EVENT_READY | Generates the NVM ready interrupts on flash sequence completion
|
◆ XMC_FLASH_HARDREAD_LEVEL_t
Defines hard read levels for strict data verification. Use type XMC_FLASH_HARDREAD_LEVEL_t for this enum. These hardread levels provide some margin to ensure that the data is really programmed with suitably distinct levels for written and erased bits.
Enumerator |
---|
XMC_FLASH_HARDREAD_LEVEL_NORMAL | No hardread level verification enabled (Normal read)
|
XMC_FLASH_HARDREAD_LEVEL_WRITTEN | Enables strict margin compare for written data cells
|
XMC_FLASH_HARDREAD_LEVEL_ERASED | Enables strict margin compare for erased data cells
|
◆ XMC_FLASH_STATUS_t
Defines the status of flash, to verify the flash related API calls. Use type XMC_FLASH_STATUS_t for this enum. The members defines the respective masked status bits of NVMSTATUS register.
Enumerator |
---|
XMC_FLASH_STATUS_OK | Flash related operation was successfully completed
|
XMC_FLASH_STATUS_BUSY | Cannot execute the flash request because another operation is in progress
|
XMC_FLASH_STATUS_SLEEP_MODE | Flash is in sleep mode
|
XMC_FLASH_STATUS_VERIFY_ERROR | Flash reported a verification failure
|
XMC_FLASH_STATUS_ECC1_READ_ERROR | Flash reports a single bit failure, and it is automatically corrected.
|
XMC_FLASH_STATUS_ECC2_READ_ERROR | Flash reported at least two bit failure
|
XMC_FLASH_STATUS_WRITE_PROTOCOL_ERROR | Write/Verify operation on a block is failed due to protocol violations or write protected sectors
|
◆ XMC_FLASH_ClearStatus()
void XMC_FLASH_ClearStatus |
( |
void |
| ) |
|
- Parameters
-
- Returns
- None
- Description:
- Clears the previous error status by reseting the ECC and VERR error status bits of NVMSTATUS register.
Call this API before starting any flash programming / erase related APIs to ensure all previous errors are cleared.
- Related APIs:
- None
◆ XMC_FLASH_DisableEvent()
void XMC_FLASH_DisableEvent |
( |
const uint32_t |
event_msk | ) |
|
- Parameters
-
- Returns
- None
- Description:
- Disables the particular flash events as specified in the input parameter.
- Related APIs:
- XMC_FLASH_EnableEvent()
◆ XMC_FLASH_EnableEvent()
void XMC_FLASH_EnableEvent |
( |
const uint32_t |
event_msk | ) |
|
- Parameters
-
- Returns
- None
- Description:
- Enables the particular flash events as specified in the input parameter.
- Related APIs:
- XMC_FLASH_DisableEvent()
◆ XMC_FLASH_EnterSleepMode()
void XMC_FLASH_EnterSleepMode |
( |
void |
| ) |
|
- Parameters
-
- Returns
- None
- Description:
- Enables the flash to enter into sleep mode by resetting the NVMCONF register NVM_ON bit.
Flash can wake up from sleep mode on any flash operation completion ready event trigger. To disable the sleep mode any time during execution call the API XMC_FLASH_ExitSleepMode().
- Related APIs:
- XMC_FLASH_ExitSleepMode()
◆ XMC_FLASH_ErasePage()
int32_t XMC_FLASH_ErasePage |
( |
uint32_t * |
address | ) |
|
- Parameters
-
address | Pointer to the starting address of the page to be erased |
- Returns
- Status of operation (NVM_STATUS)
- Description:
- Erases a single flash page associated to the specified address.
XMC1000 Flash can be erased with granularity of one page = 16 blocks of 16 Bytes = 256 Bytes using this API. It internally calls the Flash Firmware routine XMC1000_NvmErasePage(unsigned long pageAddr) to perform the erase operation. Refer XMC1000 reference manual for more details on flash firmware routines (Section 25.3). Call XMC_FLASH_GetStatus() API after calling this API, to verify the erase operation.
- Related APIs:
- XMC_FLASH_ErasePages()
◆ XMC_FLASH_ErasePages()
int32_t XMC_FLASH_ErasePages |
( |
uint32_t * |
address, |
|
|
uint32_t |
num_pages |
|
) |
| |
- Parameters
-
address | Pointer to the starting address of the flash page from where the erase starts |
num_pages | Number of pages to be erased.
Range: [1 to (flash size / 256)] |
- Returns
- Status of operation (NVM_STATUS)
- Description:
- Erases a set of flash memory pages.
Erase starts from the specified address. It erases a maximum number of num_pages flash pages. The maximum erasable pages are limited to microcontroller flash size. It sets NVMPROG register to continuous page erase mode before erase and resets it action back to normal state on completion. Call XMC_FLASH_GetStatus() after calling this API to verify the erase operation.
- Note:
- Flash will be in busy state during erase operation. Hence no operations on flash are allowed until it completes.
- Related APIs:
- XMC_FLASH_EraseSector(), XMC_FLASH_ErasePage()
- Related APIs:
- None
◆ XMC_FLASH_EraseSector()
int32_t XMC_FLASH_EraseSector |
( |
uint32_t * |
address | ) |
|
- Parameters
-
address | Pointer to the starting address of the page to be erased. |
- Returns
- Status of operation (NVM_STATUS)
- Description:
- Erases a complete sector starting from the address specified.
XMC1000 Flash can be erased with granularity of one page = 16 blocks of 16 Bytes = 256 Bytes using this API. It internally calls XMC_FLASH_ErasePages API 16 times starting from the first page of the sector.. Call XMC_FLASH_GetStatus() API after calling this API, to verify the erase operation.
- Related APIs:
- XMC_FLASH_ErasePages()
◆ XMC_FLASH_ExitSleepMode()
void XMC_FLASH_ExitSleepMode |
( |
void |
| ) |
|
◆ XMC_FLASH_GetSectorAddress()
uint32_t XMC_FLASH_GetSectorAddress |
( |
uint32_t |
sector | ) |
|
- Parameters
-
sector | Flash sector number for which the address extraction is needed
Range: [0 to 51] |
- Returns
- uint32_t Starting address of the sector specified
Range: [0x10001000 to 0x10032000]
- Description:
- Finds the starting address of the specified sector number.
- Related APIs:
- None
< Starting address of flash for XMC1 family of microcontrollers
< Number of bytes in a sector. (16 pages * 256 bytes = 4096 bytes)
◆ XMC_FLASH_GetStatus()
uint32_t XMC_FLASH_GetStatus |
( |
void |
| ) |
|
- Parameters
-
- Returns
- uint32_t Status of the previous flash operation.
- Description:
- Informs the status of flash by reading the NVMSTATUS register.
It indicates the ECC, VERR(verification error), WRPERR (Write protocol error) errors as well as the current flash state. After calling the flash read/write/erase operation related APIs, call this API to get the verification status. The return value of this API shall be checked against the members of XMC_FLASH_STATUS_t enumeration to get the relevant status.
- Related APIs:
- None
◆ XMC_FLASH_IsBusy()
bool XMC_FLASH_IsBusy |
( |
void |
| ) |
|
◆ XMC_FLASH_ProgramPage()
int32_t XMC_FLASH_ProgramPage |
( |
uint32_t * |
address, |
|
|
const uint32_t * |
data |
|
) |
| |
- Parameters
-
address | Pointer to the starting address of flash page from where the programming starts. |
data | Pointer to the source address where targeted data is located. |
- Returns
- Status of operation (NVM_STATUS)
- Description:
- Programs a single flash page associated with the specified address.
XMC1000 Flash can be programmed with one page (256 bytes) using this API. It calls the Flash Firmware routine XMC1000_NvmProgVerify(unsigned long pageAddr) to perform the programming. Refer XMC1000 reference manual of for more details on flash firmware routines (Section 25.3). Call XMC_FLASH_GetStatus() API after calling this API, to verify the programming operation.
- Note:
- Flash will be busy state during write is ongoing, hence no operations allowed until it completes.
- Related APIs:
- None
◆ XMC_FLASH_ProgramVerifyPage()
int32_t XMC_FLASH_ProgramVerifyPage |
( |
uint32_t * |
address, |
|
|
const uint32_t * |
data |
|
) |
| |
- Parameters
-
address | Pointer to the starting address of flash page from where the programming starts. |
data | Pointer to the source address where targeted data blocks are located. |
- Returns
- Status of operation (NVM_STATUS)
- Description:
- Erases, programs and verifies a single flash page starting from the address specified.
XMC1000 Flash can be programmed with granularity of one page = 16 blocks of 16 Bytes = 256 Bytes using this API. It internally calls the Flash Firmware routine XMC1000_NvmProgVerify(unsigned long pageAddr) to perform the programming. Refer XMC1000 reference manual of for more details on flash firmware routines (Section 25.3). Call XMC_FLASH_GetStatus() API after calling this API, to verify the erase operation.
- Related APIs:
- None
◆ XMC_FLASH_ReadBlocks()
void XMC_FLASH_ReadBlocks |
( |
uint32_t * |
address, |
|
|
uint32_t * |
data, |
|
|
uint32_t |
num_blocks |
|
) |
| |
- Parameters
-
address | Pointer to the starting address of flash block from where the read starts. |
data | Pointer to the destination address, where the read data blocks to be stored. |
num_blocks | Number of blocks to be read.
Range: [1 to (flash size / 16)] |
- Returns
- None
- Description:
- Reads multiple blocks from flash in one shot, starting from the address specified.
The read blocks are stored into the locations starting from the data address. Calling XMC_FLASH_GetStatus() API after calling this API verifies the read operation.
- Related APIs:
- None
◆ XMC_FLASH_ReadWord()
uint32_t XMC_FLASH_ReadWord |
( |
const uint32_t *const |
address | ) |
|
- Parameters
-
address | Pointer to the flash word address from where the read is expected |
- Returns
a 32bit data word stored in the specified address.
- Description:
- Reads a single word from the specified flashaddress.
Calling XMC_FLASH_GetStatus() API after calling this API returns the read status.
- Related APIs:
- XMC_FLASH_ReadBlocks()
◆ XMC_FLASH_SetHardReadLevel()
- Parameters
-
level | Hard read levels specified in XMC_FLASH_HARDREAD_LEVEL_t. |
- Returns
- None
- Description:
- Sets the hard read level for verification process.
It insists the flash to do a strict margin compare with the written/erased data against the internal buffer. Sets the NVMCONF register HRLEV field with level value. This hardread level is used until the end of the verification sequence and, may not be changed in between.
- Related APIs:
- None
◆ XMC_FLASH_SetSectorProtection()
void XMC_FLASH_SetSectorProtection |
( |
uint32_t |
num_sectors | ) |
|
- Parameters
-
num_sectors | Number of sectors to be protected
Range: [0 to 51] |
- Returns
- None
- Description:
- Protect the flash sectors starting from 0th sector to the specified num_sectors.
It sets the NVMCONF register SECPROT field with the value specified in num_sectors. Changing the protection limit can be achieved by calling this API at runtime with a different value of num_sectors.
- Related APIs:
- None
◆ XMC_FLASH_VerifyBlocks()
void XMC_FLASH_VerifyBlocks |
( |
uint32_t * |
address, |
|
|
const uint32_t * |
data, |
|
|
uint32_t |
num_blocks |
|
) |
| |
- Parameters
-
address | Pointer to the starting address of flash block from where the verification starts. |
data | Pointer to the source address where targeted data blocks are located. |
num_blocks | Maximum number of flash blocks writes needed.
Range: [1 to (flash size / 16)] |
- Returns
- None
- Description:
- Performs verification of written data blocks.
After calling XMC_FLASH_WriteBlocks() API, calling this API will verify the correctness of written blocks. It sets the NVMPROG register into continuous block write mode before write and resets it action back to normal state on completion. It reads back the written data blocks from the flash and verify the values against the internal buffer values. Calling XMC_FLASH_GetStatus() API after calling this API validates the result of verification.
- Related APIs:
- None
◆ XMC_FLASH_WriteBlocks()
void XMC_FLASH_WriteBlocks |
( |
uint32_t * |
address, |
|
|
const uint32_t * |
data, |
|
|
uint32_t |
num_blocks, |
|
|
bool |
verify |
|
) |
| |
- Parameters
-
address | Pointer to the starting address of flash block from where the write starts. |
data | Pointer to the source address where targeted data blocks are located. |
num_blocks | Maximum number of flash block writes needed.
Range: [1 to (flash size / 16)] |
verify | If true, hardware verification after block write is enabled else disabled. |
- Returns
- None
- Description:
- Writes a set of data blocks into the flash.
Minimum possible writable area is 16 byte block. It sets the NVMPROG register to continuous block write mode before write and resets it action back to normal state on completion. Call XMC_FLASH_GetStatus() API after calling this API to verify the erase operation.
- Note
- Flash will be busy state during write is ongoing, hence no operations allowed until it completes.
- Related APIs:
- None