XMC Peripheral Library for XMC4000 Family
2.1.16
|
Enumerations |
Detailed Description
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 function to program a page. ( XMC_FLASH_ProgramPage() )
-
Provides functions to support read and write protection. ( XMC_FLASH_InstallProtection(), XMC_FLASH_ConfirmProtection(), XMC_FLASH_VerifyReadProtection(), XMC_FLASH_VerifyWriteProtection() )
-
Provides function to erase sector. ( XMC_FLASH_EraseSector() )
Macro Definition Documentation
#define XMC_FLASH_BYTES_PER_PAGE (256UL) |
Number of bytes in a page
#define XMC_FLASH_BYTES_PER_UCB (1024UL) |
Number of bytes in a user configurable block Note : Total number of Sectors depends on the flash size of the controller. So while using these macros for flash operations ensure that sector is available, other may lead to flash error.
#define XMC_FLASH_PHY_SECTOR_0 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x00000UL) |
Starting address of non cached physical sector0
#define XMC_FLASH_PHY_SECTOR_10 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x80000UL) |
Starting address of non cached physical sector10
#define XMC_FLASH_PHY_SECTOR_11 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0xC0000UL) |
Starting address of non cached physical sector11
#define XMC_FLASH_PHY_SECTOR_12 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x100000UL) |
Starting address of non cached physical sector12
#define XMC_FLASH_PHY_SECTOR_13 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x140000UL) |
Starting address of non cached physical sector13
#define XMC_FLASH_PHY_SECTOR_14 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x180000UL) |
Starting address of non cached physical sector14
#define XMC_FLASH_PHY_SECTOR_15 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x1C0000UL) |
Starting address of non cached physical sector15
#define XMC_FLASH_PHY_SECTOR_4 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x10000UL) |
Starting address of non cached physical sector4
#define XMC_FLASH_PHY_SECTOR_8 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x20000UL) |
Starting address of non cached physical sector8
#define XMC_FLASH_PHY_SECTOR_9 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x40000UL) |
Starting address of non cached physical sector9
#define XMC_FLASH_SECTOR_0 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x00000UL) |
Starting address of sector0
#define XMC_FLASH_SECTOR_1 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x04000UL) |
Starting address of sector1
#define XMC_FLASH_SECTOR_10 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x80000UL) |
Starting address of sector10
#define XMC_FLASH_SECTOR_11 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0xC0000UL) |
Starting address of sector11
#define XMC_FLASH_SECTOR_12 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x100000UL) |
Starting address of sector12
#define XMC_FLASH_SECTOR_13 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x140000UL) |
Starting address of sector13
#define XMC_FLASH_SECTOR_14 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x180000UL) |
Starting address of sector14
#define XMC_FLASH_SECTOR_15 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x1C0000UL) |
Starting address of sector15
#define XMC_FLASH_SECTOR_2 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x08000UL) |
Starting address of sector2
#define XMC_FLASH_SECTOR_3 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x0C000UL) |
Starting address of sector3
#define XMC_FLASH_SECTOR_4 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x10000UL) |
Starting address of sector4
#define XMC_FLASH_SECTOR_5 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x14000UL) |
Starting address of sector5
#define XMC_FLASH_SECTOR_6 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x18000UL) |
Starting address of sector6
#define XMC_FLASH_SECTOR_7 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x1C000UL) |
Starting address of sector7
#define XMC_FLASH_SECTOR_8 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x20000UL) |
Starting address of sector8
#define XMC_FLASH_SECTOR_9 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x40000UL) |
Starting address of sector9
#define XMC_FLASH_UCB0 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x0000UL) |
Starting address of User Configurable Block 0
#define XMC_FLASH_UCB1 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x0400UL) |
Starting address of User Configurable Block 1
#define XMC_FLASH_UCB2 (uint32_t *)(XMC_FLASH_UNCACHED_BASE + 0x0800UL) |
Starting address of User Configurable Block 2
#define XMC_FLASH_UNCACHED_BASE (0x0C000000U) |
Non cached flash starting address of for XMC4 family of microcontrollers
#define XMC_FLASH_WORDS_PER_PAGE (64UL) |
Number of words in a page (256 bytes / 4 bytes = 64 words)
Enumeration Type Documentation
enum XMC_FLASH_EVENT_t |
Provides the options to select flash operational events
enum XMC_FLASH_MARGIN_t |
Provides the options to select sectors for write protection and select global read protection. The members can be combined using 'OR' operator for multiple selection.
enum XMC_FLASH_STATUS_t |
Defines the return status of the API.
Function Documentation
void XMC_FLASH_ClearStatus | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Clears the previous error status by reseting the FSR status register.
Call this API before starting any flash programming / erase related APIs to ensure all previous errors are cleared.
- Related APIs:
- None
void XMC_FLASH_ConfirmProtection | ( | uint8_t | user | ) |
- Parameters
-
user ID number of the user configuration block (UCB).
Range: [0 to 2]
- Returns
- None
- Description:
- Confirms the protection, so that sectors specified under user configurable block are locked forever.
The protection shall be installed by calling XMC_FLASH_InstallProtection() before calling this API. The confirmation starts by issuing the page mode entry command followed by the load page command. The load page command issues the confirmation protection command for the sectors on which the protection installation was done. It also loads the specified passwords password0 and password1 respectively. Finally, it issues the confirm protection command for the specified user configuration block so that the sectors will be protected forever.
- Related APIs:
- XMC_FLASH_InstallProtection()
void XMC_FLASH_DisableDoubleBitErrorTrap | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Disables the trap generation for double bit error by clearing MARP register bit TRAPDIS.
The double-bit error trap can be disabled for margin checks and also redirected to an error interrupt. Any time during the execution the double bit error trap can be enabled back by calling XMC_FLASH_EnableDoubleBitErrorTrap() API.
- Related APIs:
- None
void XMC_FLASH_DisableDynamicIdle | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Disables dynamic idle mode feature.
It resets the FCON register IDLE bit to disable this feature. Hence normal flash read operation is selected.
- Related APIs:
- XMC_FLASH_EnableDynamicIdle()
void XMC_FLASH_DisableEvent | ( | const uint32_t | event_msk | ) |
- Parameters
-
event_msk ORed values of XMC_FLASH_EVENT_t enumeration
- Returns
- None
- Description:
- Disables the particular flash events as specified in the input parameter.
- Related APIs:
- XMC_FLASH_EnableEvent()
void XMC_FLASH_DisableSleepRequest | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Wake-up the PFLASH from sleep.
Wakes-up from sleep is done by clearing the bit FCON.SLEEP, if selected via this bit, or wake-up is initiated by releasing the external sleep signal from SCU.
- Note:
- fCPU must be equal or above 1 MHz when wake-up request is triggered.
- Related APIs:
- XMC_FLASH_EnableSleepRequest()
void XMC_FLASH_DisableWaitStateForECC | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Disables the wait state for error correction.
Removes additional wait state for ECC by resetting WSECPF bit of FCON register.
- Related APIs:
- XMC_FLASH_EnableWaitStateForECC()
void XMC_FLASH_EnableDoubleBitErrorTrap | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Enables double bit error trap.
. It enables by setting MARP register bit TRAPDIS.
- Related APIs:
- None
void XMC_FLASH_EnableDynamicIdle | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Enables dynamic idle mode feature to save power.
It switches off the PFLASH read path when no read access is pending. Hence power is saved marginally. This slightly reduces the flash read performance because static pre-fetching is disabled.It sets the FCON register IDLE bit to enable this feature.
- Related APIs:
- XMC_FLASH_DisableDynamicIdle()
void XMC_FLASH_EnableEvent | ( | const uint32_t | event_msk | ) |
- Parameters
-
event_msk ORed values of XMC_FLASH_EVENT_t enumeration
- Returns
- None
- Description:
- Enables the particular flash events as specified in the input parameter.
- Related APIs:
- XMC_FLASH_DisableEvent()
void XMC_FLASH_EnableSleepRequest | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Enables sleep mode of the PFLASH.
Sleep mode is enabled by setting the bit FCON.SLEEP.
- Note:
- fCPU must be equal or above 1 MHz when wake-up request is triggered.
- Related APIs:
- XMC_FLASH_DisableSleepRequest()
void XMC_FLASH_EnableWaitStateForECC | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Enables the wait state for error correction.process, It enables one additional wait state for ECC by setting WSECPF bit of FCON register.
- Related APIs:
- XMC_FLASH_DisableWaitStateForECC()
void XMC_FLASH_ErasePhysicalSector | ( | uint32_t * | sector_start_address | ) |
- Parameters
-
sector_start_address Pointer to the starting address of physical sector. Use XMC_FLASH_SECTOR_x MACRO defined in xmc4_flash.h file.
- Returns
- None
- Description:
- Erases the physical sector "PSA".
If "PSA" does not point to base address of a correct sector or an unavailable sector, it returns SQER.
- Related APIs:
- None
void XMC_FLASH_EraseSector | ( | uint32_t * | address | ) |
- Parameters
-
address Pointer to the starting address of the page to be erased.
- Returns
- None
- Description:
Erases a sector associated with the specified address.
Before erase, it clears the error status bits inside FSR status register. Issues the erase sector command sequence with the specified starting address to start flash erase process. Call XMC_FLASH_GetStatus() API after calling this API, to verify the erase operation.
- Related APIs:
- None
void XMC_FLASH_EraseUCB | ( | uint32_t * | ucb_sector_start_address | ) |
- Parameters
-
ucb_sector_start_address Pointer to the starting address of physical sector. Use XMC_FLASH_UCBx MACRO defined in xmc4_flash.h file.
- Returns
- None
- Description:
- The addressed user configuration block �UCB� is erased.
Erases UCB whose startting address specified in the input parameter ucb_sector_start_address. When the UCB has an active write protection or the Flash module has an active global read protection the execution fails and PROER is set. The command fails with SQER when ucb_sector_start_address is not the start address of a valid UCB. Call XMC_FLASH_GetStatus API after this API to verify the erase was proper ot not.
- Related APIs:
- None
uint32_t XMC_FLASH_GetStatus | ( | void | ) |
- Parameters
-
None
- Returns
- uint32_t Status of the previous flash operation.
- Description:
- Informs the status of flash by reading the FSR register.
It indicates the error status such as PFOPER, SQER, PROER, PFDBER, ORIER, VER errors as well as the current flash state. After calling the flash read/write/erase operation related APIs, call this API to verify flash 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
void XMC_FLASH_InstallProtection | ( | uint8_t | user, |
uint32_t | protection_mask, | ||
uint32_t | password_0, | ||
uint32_t | password_1 | ||
) |
- Parameters
-
user ID number of the user configuration block (UCB).
Range: [0 to 2]protection_mask ORed values of XMC_FLASH_PROTECTION_t enum type, for which sectors the protection has to be enabled. password_0 First password for protection.
Range: [0 to 4294967295]password_1 Second password for protection.
Range: [0 to 4294967295]
- Returns
- None
- Description:
- Installs the global read and sector write protection.
The installation starts by issuing the page mode entry command followed by the load page command. The load page command mode loads the required sectors intended for protection specified in protection_mask. It also loads the specified passwords password0 and password1 respectively. Finally, it issues the write page command for the specified user configuration block. Calling XMC_FLASH_ConfirmProtection() after this API completes the protection process by freezing the sectors forever.
bool XMC_FLASH_IsBusy | ( | void | ) |
- Parameters
-
None
- Returns
- true if flash is in busy state else returns false.
- Description:
- Checks whether flash is in busy state or not.
It is checked by calling the XMC_FLASH_GetStatus() API internally. Refer XMC_FLASH_GetStatus() for more details.
- Related APIs:
- XMC_FLASH_GetStatus()
void 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
- None
- Description:
- Programs a single flash page associated with the specified address.
XMC4000 flash can be programmed with a granularity of 256 bytes page using this API. Before entering into page write process, it clears the error status bits inside status register. It starts the write process by issuing the page mode command followed by the load page command which loads the targeted data blocks into internal assembly buffer. Finally, it issues the write page command which programs the data into flash. 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
void XMC_FLASH_RepairPhysicalSector | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Repairs the physical sector "PS4".
For selected devices, Erase Physical Sector can also be used for Sector Soft Repair, depending on the configuration of PROCON1.PSR. This command sequence is required to run an EEPROM emulation algorithm that cycles the logical sectors S4..S7 of PS4. This command sequence repairs the corrupted logical sectors inside the physical sector due to interrupted erase operation.
- Related APIs:
- None
void XMC_FLASH_Reset | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Resets the command interpreter to its initial state.
Reset to Read can cancel every command sequence before its last command cycle has been received. All error flags gets cleared by calling this API.
- Note:
- todo
- Related APIs:
- None
void XMC_FLASH_ResumeProtection | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Resumes flash protection as it was configured before.
It clears all the disable proection status flags FSR.WPRODISx and FSR.RPRODIS. But FSR.WPRODISx is not cleared when corresponding UCBx is not in the �confirmed� state.
- Related APIs:
- None
void XMC_FLASH_SetMargin | ( | const XMC_FLASH_MARGIN_t | margin | ) |
- Parameters
-
margin PFLASH margin selection. Use type XMC_FLASH_MARGIN_t.
- Returns
- None
- Description:
- Sets the read margin levels for checking the healthiness of flash data.
Configures the margin field of MARP MARP register with the specified margin level. It changes the margin levels for read operations to find problematic array bits.
- Related APIs:
- None
void XMC_FLASH_SetWaitStates | ( | uint32_t | num_wait_states | ) |
- Parameters
-
num_wait_states number of wait states for initial read access
Range: [0 to 15]
- Returns
- None
- Description:
- Configures the number of wait states for initial flash read access.
Depending on the configured num_wait_states value into FCON resister WSPFLASH field, the read performance gets optimized . The wait cycles for the flash read access must be configured based on the CPU frequency (fCPU), in relation to the flash access time (ta) defined. The access time formula (WSPFLASH x (1 / fCPU) >= ta) applies only for the values num_wait_states >0.
- Related APIs:
- None
bool XMC_FLASH_VerifyReadProtection | ( | uint32_t | password_0, |
uint32_t | password_1 | ||
) |
- Parameters
-
password_0 First password used for protection.
Range: [0 to 4294967295]password_1 Second password used for protection.
Range: [0 to 4294967295]
- Returns
- true if read protection installed properly else returns false.
- Description:
- Verifies sector read protection is properly installed or not.
Before entering into verify read protection process, it clears the error status bits inside status register. It temporarily disables the protection with passwords password0 and password1 respectively. It reads the FSR register and verifies the protection state. Resumption of read protection after disablement is achieved by XMC_FLASH_ResumeProtection or until next reset.
bool XMC_FLASH_VerifyWriteProtection | ( | uint32_t | user, |
uint32_t | protection_mask, | ||
uint32_t | password_0, | ||
uint32_t | password_1 | ||
) |
- Parameters
-
user ID number of the user configuration block (UCB).
Range: [0 to 2]protection_mask ORed values of XMC_FLASH_PROTECTION_t enum type, for which sectors the protection has to be verified. password_0 First password used for protection.
Range: [0 to 4294967295]password_1 Second password used for protection.
Range: [0 to 4294967295]
- Returns
- true if write protection installed properly else returns false.
- Description:
- Verifies sector read protection is properly installed or not.
Before entering into verify read protection process, it clears the error status bits inside status register. It temporarily disables the protection with passwords password0 and password1 respectively for the intended sectors specified in protection_mask. It reads the FSR register and verifies the write protection state. Resumption of write protection after disablement is achieved by XMC_FLASH_ResumeProtection or until next reset.
void XMC_PREFETCH_DisableInstructionBuffer | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Bypasses the instruction buffer for cacheable accesses, by setting the register bit PREF_PCON.IBYP.
- Related APIs:
- None
void XMC_PREFETCH_EnableInstructionBuffer | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Configures the cacheable accesses to use the instruction buffer by resetting the register bit PREF_PCON.IBYP.
- Related APIs:
- None
void XMC_PREFETCH_InvalidateInstructionBuffer | ( | void | ) |
- Parameters
-
None
- Returns
- None
- Description:
- Invalidates the instruction buffer by setting PREF_PCON register bit IINV.
After system reset, the instruction buffer is automatically invalidated.
- Note:
- The complete invalidation operation is performed in a single cycle.
- Related APIs:
- None
Generated on Mon Aug 7 2017 11:33:57 for XMC Peripheral Library for XMC4000 Family by 1.8.11