Module for erasing, programming, verifying and configuring different functionalities of the Flash IP.
More...
|
void | FlashCtl_enableReadParityCheck (uint_fast8_t memorySpace, uint_fast8_t accessMethod) |
|
void | FlashCtl_disableReadParityCheck (uint_fast8_t memorySpace, uint_fast8_t accessMethod) |
|
void | FlashCtl_enableReadBuffering (uint_fast8_t memoryBank, uint_fast8_t accessMethod) |
|
void | FlashCtl_disableReadBuffering (uint_fast8_t memoryBank, uint_fast8_t accessMethod) |
|
bool | FlashCtl_unprotectSector (uint_fast8_t memorySpace, uint32_t sectorMask) |
|
bool | FlashCtl_protectSector (uint_fast8_t memorySpace, uint32_t sectorMask) |
|
bool | FlashCtl_isSectorProtected (uint_fast8_t memorySpace, uint32_t sector) |
|
bool | FlashCtl_verifyMemory (void *verifyAddr, uint32_t length, uint_fast8_t pattern) |
|
bool | FlashCtl_performMassErase (bool verify) |
|
bool | FlashCtl_eraseSector (uint32_t addr, bool verify) |
|
bool | FlashCtl_programMemory (void *src, void *dest, uint32_t length, uint32_t verify) |
|
void | FlashCtl_setProgramVerification (uint32_t verificationSetting) |
|
void | FlashCtl_clearProgramVerification (uint32_t verificationSetting) |
|
void | FlashCtl_enableWordProgramming (uint32_t mode) |
|
void | FlashCtl_disableWordProgramming (void) |
|
uint32_t | FlashCtl_isWordProgrammingEnabled (void) |
|
bool | FlashCtl_setReadMode (uint32_t flashBank, uint32_t readMode) |
|
uint32_t | FlashCtl_getReadMode (uint32_t flashBank) |
|
void | FlashCtl_setWaitState (uint32_t bank, uint32_t waitState) |
|
uint32_t | FlashCtl_getWaitState (uint32_t bank) |
|
void | FlashCtl_enableInterrupt (uint32_t flags) |
|
void | FlashCtl_disableInterrupt (uint32_t flags) |
|
uint32_t | FlashCtl_getEnabledInterruptStatus (void) |
|
uint32_t | FlashCtl_getInterruptStatus (void) |
|
void | FlashCtl_clearInterruptFlag (uint32_t flags) |
|
void | FlashCtl_registerInterrupt (void(*intHandler)(void)) |
|
void | FlashCtl_unregisterInterrupt (void) |
|
Module for erasing, programming, verifying and configuring different functionalities of the Flash IP.
Module Operation
The MSP432 DriverLib Flash Controller peripheral is designed to simplify the process or writing, erasing, and configuring the flash memory on the MSP432 part. Many of the stringent verification requirements/preconditions are handled entirely inside the FlashCtl APIs.
Use of ROM APIs
As the verification requirements tend to be a bit code size intensive, the use of the ROM APIs for flash memory operations is a power tool at the disposal. Additionally, since the ROM APIs reside in ROM as opposed to Flash, the use of the FlashCtl ROM APIs allows the user to program/erase portions of flash memory without worrying about which flash bank the program is executing.
A typical use case of how to erase/program a portion of Flash memory can be seen in the code snippet below:
In this snippet, the correct sectors of flash that we want to program are unlocked, an erase is initiated to that corresponding sector, and finally the data that we want to program is programmed using the ROM APIs. In addition to programming MAIN memory, INFO memory can also be programmed in a similar fashion using the same APIs. By using the ROM APIs, the user does not need to worry about which memory bank the user is programming from and also does not need to worry about any manual read mode changes.
Verification Modes
The use of the DriverLib APIs allows the user to customize the verification settings of the erase/program operation that they are performing. These verification settings are made available not only to cater towards the more advanced users that might want to customize every aspect of the flash operation, but also users who want to use a predefined macro to factor out advanced programming operations.
For the FlashCtl_eraseSector and FlashCtl_performMassErase APIs, a boolean parameter is passed that gives the user the option to do a post-erase verification. Since the erase verification is not explicitly built into the MSP432 hardware, when a true value is passed for verification into these APIs a manual software verification will be performed. While it is a software verification, many hardware-centric features are utilized including burst verify and the changing of read modes to erase verify when applicable.
For the FlashCtl_programMemory API, a wide range of verification options are available. These include:
- FLASH_BURSTPOST
- FLASH_BURSTPRE
- FLASH_REGPRE
- FLASH_REGPOST
- FLASH_NOVER No verification enabled
- FLASH_FULLVER Full verification enabled
For simplicity, the FLASH_FULLVER parameter can be used which enables all levels of verification. For advanced users, different settings can be logically ORed together to get the desired level of verification. For more details on the different modes of verification, refer to the device specific user's guide.
Wait State Considerations
When changing read modes on the MSP432 microcontroller, some read modes (such as erase verify) require an additional number of wait states. The wait states of the flash controller can be configured using the FlashCtl_setWaitState command. When using functions such as FlashCtl_eraseSector and the FlashCtl_performMassErase commands from ROM, the wait states are automatically configured and reverted at the end of the operation.
Programming Examples
The DriverLib package contains a variety of different code examples that demonstrate the usage of the FlashCtl module. These code examples are accessible under the examples/ folder of the MSPWare release as well as through TI Resource Explorer if using Code Composer Studio. These code examples provide a comprehensive list of use cases as well as practical applications involving each module.
Below is a very brief code example showing how to unprotect a sector and issue a mass erase with the FlashCtl module:
#define FLASH_BURST_PRG_BIT 0x03 |
#define FLASH_PROGRAM_ERROR FLCTL_INTFLAG_PRG_ERR |
#define FLASH_BENCHMARK_INT FLCTL_INTFLAG_BMRK |
#define FLASH_BANK1_PARITY_ERROR FLCTL_INTFLAG_PARBNK1 |
#define FLASH_BANK0_PARITY_ERROR FLCTL_INTFLAG_PARBNK0 |
#define FLASH_ERASE_COMPLETE FLCTL_INTFLAG_ERASE |
#define FLASH_BRSTPRGM_COMPLETE FLCTL_INTFLAG_PRGB |
#define FLASH_WRDPRGM_COMPLETE FLCTL_INTFLAG_PRG |
#define FLASH_POSTVERIFY_FAILED FLCTL_INTFLAG_AVPST |
#define FLASH_PREVERIFY_FAILED FLCTL_INTFLAG_AVPRE |
#define FLASH_BRSTRDCMP_COMPLETE FLCTL_INTFLAG_RDBRST |
#define FLASH_MARGIN0B_READ_MODE FLCTL_RDCTL_BNK0_RD_MODE__9 |
#define FLASH_MARGIN1B_READ_MODE FLCTL_RDCTL_BNK0_RD_MODE__10 |
#define FLASH_PRGBRSTCTLSTAT_BURSTSTATUS_COMPLETE 0x70000 |
#define FLASH_DATA_READ 0x00 |
#define FLASH_INSTRUCTION_FETCH 0x01 |
#define FLASH_MAIN_MEMORY_SPACE_BANK0 0x01 |
#define FLASH_MAIN_MEMORY_SPACE_BANK1 0x02 |
#define FLASH_INFO_MEMORY_SPACE_BANK0 0x03 |
#define FLASH_INFO_MEMORY_SPACE_BANK1 0x04 |
#define FLASH_1_PATTERN FLCTL_RDBRST_CTLSTAT_DATA_CMP |
#define FLASH_0_PATTERN 0x00 |
#define FLASH_SECTOR0 FLCTL_MAINWEPROT_BNK0_PROT0 |
#define FLASH_SECTOR1 FLCTL_MAINWEPROT_BNK0_PROT1 |
#define FLASH_SECTOR2 FLCTL_MAINWEPROT_BNK0_PROT2 |
#define FLASH_SECTOR3 FLCTL_MAINWEPROT_BNK0_PROT3 |
#define FLASH_SECTOR4 FLCTL_MAINWEPROT_BNK0_PROT4 |
#define FLASH_SECTOR5 FLCTL_MAINWEPROT_BNK0_PROT5 |
#define FLASH_SECTOR6 FLCTL_MAINWEPROT_BNK0_PROT6 |
#define FLASH_SECTOR7 FLCTL_MAINWEPROT_BNK0_PROT7 |
#define FLASH_SECTOR8 FLCTL_MAINWEPROT_BNK0_PROT8 |
#define FLASH_SECTOR9 FLCTL_MAINWEPROT_BNK0_PROT9 |
#define FLASH_SECTOR10 FLCTL_MAINWEPROT_BNK0_PROT10 |
#define FLASH_SECTOR11 FLCTL_MAINWEPROT_BNK0_PROT11 |
#define FLASH_SECTOR12 FLCTL_MAINWEPROT_BNK0_PROT12 |
#define FLASH_SECTOR13 FLCTL_MAINWEPROT_BNK0_PROT13 |
#define FLASH_SECTOR14 FLCTL_MAINWEPROT_BNK0_PROT14 |
#define FLASH_SECTOR15 FLCTL_MAINWEPROT_BNK0_PROT15 |
#define FLASH_SECTOR16 FLCTL_MAINWEPROT_BNK0_PROT16 |
#define FLASH_SECTOR17 FLCTL_MAINWEPROT_BNK0_PROT17 |
#define FLASH_SECTOR18 FLCTL_MAINWEPROT_BNK0_PROT18 |
#define FLASH_SECTOR19 FLCTL_MAINWEPROT_BNK0_PROT19 |
#define FLASH_SECTOR20 FLCTL_MAINWEPROT_BNK0_PROT20 |
#define FLASH_SECTOR21 FLCTL_MAINWEPROT_BNK0_PROT21 |
#define FLASH_SECTOR22 FLCTL_MAINWEPROT_BNK0_PROT22 |
#define FLASH_SECTOR23 FLCTL_MAINWEPROT_BNK0_PROT23 |
#define FLASH_SECTOR24 FLCTL_MAINWEPROT_BNK0_PROT24 |
#define FLASH_SECTOR25 FLCTL_MAINWEPROT_BNK0_PROT25 |
#define FLASH_SECTOR26 FLCTL_MAINWEPROT_BNK0_PROT26 |
#define FLASH_SECTOR27 FLCTL_MAINWEPROT_BNK0_PROT27 |
#define FLASH_SECTOR28 FLCTL_MAINWEPROT_BNK0_PROT28 |
#define FLASH_SECTOR29 FLCTL_MAINWEPROT_BNK0_PROT29 |
#define FLASH_SECTOR30 FLCTL_MAINWEPROT_BNK0_PROT30 |
#define FLASH_SECTOR31 FLCTL_MAINWEPROT_BNK0_PROT31 |
#define FLASH_BURSTPOST FLCTL_PRGBRST_CTLSTAT_AUTO_PST |
#define FLASH_BURSTPRE FLCTL_PRGBRST_CTLSTAT_AUTO_PRE |
#define FLASH_REGPRE FLCTL_PRG_CTLSTAT_VER_PRE |
#define FLASH_REGPOST FLCTL_PRG_CTLSTAT_VER_PST |
Value:(FLCTL_PRGBRST_CTLSTAT_AUTO_PST | \
FLCTL_PRGBRST_CTLSTAT_AUTO_PRE | FLCTL_PRG_CTLSTAT_VER_PRE \
| FLCTL_PRG_CTLSTAT_VER_PST)
#define FLASH_COLLATED_WRITE_MODE 0x01 |
#define FLASH_IMMEDIATE_WRITE_MODE 0x02 |
void FlashCtl_enableReadParityCheck |
( |
uint_fast8_t |
memorySpace, |
|
|
uint_fast8_t |
accessMethod |
|
) |
| |
Enables parity checking on accesses to a specified bank of flash memory
- Parameters
-
memorySpace | is the value of the memory bank to enable parity checks. Must be only one of the following values:
- FLASH_MAIN_MEMORY_SPACE_BANK0,
- FLASH_MAIN_MEMORY_SPACE_BANK1,
- FLASH_INFO_MEMORY_SPACE_BANK0,
- FLASH_INFO_MEMORY_SPACE_BANK1
|
accessMethod | is the value of the access type to enable parity checks. Must be only one of the following values:
- FLASH_DATA_READ,
- FLASH_INSTRUCTION_FETCH
|
- Returns
- None.
References ASSERT, FLASH_DATA_READ, FLASH_INFO_MEMORY_SPACE_BANK0, FLASH_INFO_MEMORY_SPACE_BANK1, FLASH_INSTRUCTION_FETCH, FLASH_MAIN_MEMORY_SPACE_BANK0, and FLASH_MAIN_MEMORY_SPACE_BANK1.
void FlashCtl_disableReadParityCheck |
( |
uint_fast8_t |
memorySpace, |
|
|
uint_fast8_t |
accessMethod |
|
) |
| |
Disables parity checking on accesses to a specified bank of flash memory
- Parameters
-
memorySpace | is the value of the memory bank to disable parity checks. Must be only one of the following values:
- FLASH_MAIN_MEMORY_SPACE_BANK0,
- FLASH_MAIN_MEMORY_SPACE_BANK1,
- FLASH_INFO_MEMORY_SPACE_BANK0,
- FLASH_INFO_MEMORY_SPACE_BANK1
|
accessMethod | is the value of the access type to disable parity checks. Must be only one of the following values:
- FLASH_DATA_READ,
- FLASH_INSTRUCTION_FETCH
|
- Returns
- None.
References ASSERT, FLASH_DATA_READ, FLASH_INFO_MEMORY_SPACE_BANK0, FLASH_INFO_MEMORY_SPACE_BANK1, FLASH_INSTRUCTION_FETCH, FLASH_MAIN_MEMORY_SPACE_BANK0, and FLASH_MAIN_MEMORY_SPACE_BANK1.
void FlashCtl_enableReadBuffering |
( |
uint_fast8_t |
memoryBank, |
|
|
uint_fast8_t |
accessMethod |
|
) |
| |
Enables read buffering on accesses to a specified bank of flash memory
- Parameters
-
memoryBank | is the value of the memory bank to enable read buffering. Must be only one of the following values:
|
accessMethod | is the value of the access type to enable read buffering. Must be only one of the following values:
- FLASH_DATA_READ,
- FLASH_INSTRUCTION_FETCH
|
- Returns
- None.
References ASSERT, FLASH_BANK0, FLASH_BANK1, FLASH_DATA_READ, and FLASH_INSTRUCTION_FETCH.
void FlashCtl_disableReadBuffering |
( |
uint_fast8_t |
memoryBank, |
|
|
uint_fast8_t |
accessMethod |
|
) |
| |
Disables read buffering on accesses to a specified bank of flash memory
- Parameters
-
memoryBank | is the value of the memory bank to disable read buffering. Must be only one of the following values:
|
accessMethod | is the value of the access type to disable read buffering. Must ne only one of the following values:
- FLASH_DATA_READ,
- FLASH_INSTRUCTION_FETCH
|
- Returns
- None.
References ASSERT, FLASH_BANK0, FLASH_BANK1, FLASH_DATA_READ, and FLASH_INSTRUCTION_FETCH.
bool FlashCtl_unprotectSector |
( |
uint_fast8_t |
memorySpace, |
|
|
uint32_t |
sectorMask |
|
) |
| |
Disables program protection on the given sector mask. This setting can be applied on a sector-wise bases on a given memory space (INFO or MAIN).
- Parameters
-
memorySpace | is the value of the memory bank to disable program protection. Must be only one of the following values:
- FLASH_MAIN_MEMORY_SPACE_BANK0,
- FLASH_MAIN_MEMORY_SPACE_BANK1,
- FLASH_INFO_MEMORY_SPACE_BANK0,
- FLASH_INFO_MEMORY_SPACE_BANK1
|
sectorMask | is a bit mask of the sectors to disable program protection. Must be a bitfield of the following values:
- FLASH_SECTOR0,
- FLASH_SECTOR1,
- FLASH_SECTOR2,
- FLASH_SECTOR3,
- FLASH_SECTOR4,
- FLASH_SECTOR5,
- FLASH_SECTOR6,
- FLASH_SECTOR7,
- FLASH_SECTOR8,
- FLASH_SECTOR9,
- FLASH_SECTOR10,
- FLASH_SECTOR11,
- FLASH_SECTOR12,
- FLASH_SECTOR13,
- FLASH_SECTOR14,
- FLASH_SECTOR15,
- FLASH_SECTOR16,
- FLASH_SECTOR17,
- FLASH_SECTOR18,
- FLASH_SECTOR19,
- FLASH_SECTOR20,
- FLASH_SECTOR21,
- FLASH_SECTOR22,
- FLASH_SECTOR23,
- FLASH_SECTOR24,
- FLASH_SECTOR25,
- FLASH_SECTOR26,
- FLASH_SECTOR27,
- FLASH_SECTOR28,
- FLASH_SECTOR29,
- FLASH_SECTOR30,
- FLASH_SECTOR31
|
- Note
- Flash sector sizes are 4KB and the number of sectors may vary depending on the specific device. Also, for INFO memory space, only sectors FLASH_SECTOR0 and FLASH_SECTOR1 will exist.
- Returns
- true if sector protection disabled false otherwise.
References ASSERT, FLASH_INFO_MEMORY_SPACE_BANK0, FLASH_INFO_MEMORY_SPACE_BANK1, FLASH_MAIN_MEMORY_SPACE_BANK0, FLASH_MAIN_MEMORY_SPACE_BANK1, and FlashCtl_isSectorProtected().
bool FlashCtl_protectSector |
( |
uint_fast8_t |
memorySpace, |
|
|
uint32_t |
sectorMask |
|
) |
| |
Enables program protection on the given sector mask. This setting can be applied on a sector-wise bases on a given memory space (INFO or MAIN).
- Parameters
-
memorySpace | is the value of the memory bank to enable program protection. Must be only one of the following values:
- FLASH_MAIN_MEMORY_SPACE_BANK0,
- FLASH_MAIN_MEMORY_SPACE_BANK1,
- FLASH_INFO_MEMORY_SPACE_BANK0,
- FLASH_INFO_MEMORY_SPACE_BANK1
|
sectorMask | is a bit mask of the sectors to enable program protection. Must be a bitfield of the following values:
- FLASH_SECTOR0,
- FLASH_SECTOR1,
- FLASH_SECTOR2,
- FLASH_SECTOR3,
- FLASH_SECTOR4,
- FLASH_SECTOR5,
- FLASH_SECTOR6,
- FLASH_SECTOR7,
- FLASH_SECTOR8,
- FLASH_SECTOR9,
- FLASH_SECTOR10,
- FLASH_SECTOR11,
- FLASH_SECTOR12,
- FLASH_SECTOR13,
- FLASH_SECTOR14,
- FLASH_SECTOR15,
- FLASH_SECTOR16,
- FLASH_SECTOR17,
- FLASH_SECTOR18,
- FLASH_SECTOR19,
- FLASH_SECTOR20,
- FLASH_SECTOR21,
- FLASH_SECTOR22,
- FLASH_SECTOR23,
- FLASH_SECTOR24,
- FLASH_SECTOR25,
- FLASH_SECTOR26,
- FLASH_SECTOR27,
- FLASH_SECTOR28,
- FLASH_SECTOR29,
- FLASH_SECTOR30,
- FLASH_SECTOR31
|
- Note
- Flash sector sizes are 4KB and the number of sectors may vary depending on the specific device. Also, for INFO memory space, only sectors FLASH_SECTOR0 and FLASH_SECTOR1 will exist.
- Returns
- true if sector protection enabled false otherwise.
References ASSERT, FLASH_INFO_MEMORY_SPACE_BANK0, FLASH_INFO_MEMORY_SPACE_BANK1, FLASH_MAIN_MEMORY_SPACE_BANK0, FLASH_MAIN_MEMORY_SPACE_BANK1, and FlashCtl_isSectorProtected().
bool FlashCtl_isSectorProtected |
( |
uint_fast8_t |
memorySpace, |
|
|
uint32_t |
sector |
|
) |
| |
Returns the sector protection for given sector mask and memory space
- Parameters
-
memorySpace | is the value of the memory bank to check for program protection. Must be only one of the following values:
- FLASH_MAIN_MEMORY_SPACE_BANK0,
- FLASH_MAIN_MEMORY_SPACE_BANK1,
- FLASH_INFO_MEMORY_SPACE_BANK0,
- FLASH_INFO_MEMORY_SPACE_BANK1
|
sector | is the sector to check for program protection. Must be one of the following values:
- FLASH_SECTOR0,
- FLASH_SECTOR1,
- FLASH_SECTOR2,
- FLASH_SECTOR3,
- FLASH_SECTOR4,
- FLASH_SECTOR5,
- FLASH_SECTOR6,
- FLASH_SECTOR7,
- FLASH_SECTOR8,
- FLASH_SECTOR9,
- FLASH_SECTOR10,
- FLASH_SECTOR11,
- FLASH_SECTOR12,
- FLASH_SECTOR13,
- FLASH_SECTOR14,
- FLASH_SECTOR15,
- FLASH_SECTOR16,
- FLASH_SECTOR17,
- FLASH_SECTOR18,
- FLASH_SECTOR19,
- FLASH_SECTOR20,
- FLASH_SECTOR21,
- FLASH_SECTOR22,
- FLASH_SECTOR23,
- FLASH_SECTOR24,
- FLASH_SECTOR25,
- FLASH_SECTOR26,
- FLASH_SECTOR27,
- FLASH_SECTOR28,
- FLASH_SECTOR29,
- FLASH_SECTOR30,
- FLASH_SECTOR31
|
Note that flash sector sizes are 4KB and the number of sectors may vary depending on the specific device. Also, for INFO memory space, only sectors FLASH_SECTOR0 and FLASH_SECTOR1 will exist.
- Returns
- true if sector protection enabled false otherwise.
References ASSERT, FLASH_INFO_MEMORY_SPACE_BANK0, FLASH_INFO_MEMORY_SPACE_BANK1, FLASH_MAIN_MEMORY_SPACE_BANK0, and FLASH_MAIN_MEMORY_SPACE_BANK1.
Referenced by FlashCtl_protectSector(), and FlashCtl_unprotectSector().
bool FlashCtl_verifyMemory |
( |
void * |
verifyAddr, |
|
|
uint32_t |
length, |
|
|
uint_fast8_t |
pattern |
|
) |
| |
Verifies a given segment of memory based off either a high (1) or low (0) state.
- Parameters
-
verifyAddr | Start address where verification will begin |
length | Length in bytes to verify based off the pattern |
pattern | The pattern which verification will check versus. This can either be a low pattern (each register will be checked versus a pattern of 32 zeros, or a high pattern (each register will be checked versus a pattern of 32 ones). Valid values are: FLASH_0_PATTERN, FLASH_1_PATTERN |
Note that there are no sector/boundary restrictions for this function, however it is encouraged to proved a start address aligned on 32-bit boundaries. Providing an unaligned address will result in unaligned data accesses and detriment efficiency.
Note that this function is blocking and will not exit until operation has either completed or failed due to an error.
- Returns
- true if memory verification is successful, false otherwise.
References __FLASH_END__, __FLASH_START__, __INFO_FLASH_START__, ASSERT, FLASH_0_PATTERN, FLASH_1_PATTERN, FLASH_INFO_SPACE, FLASH_MAIN_SPACE, FLCTL_RDBRST_CTLSTAT_BRST_STAT__3, FLCTL_RDBRST_CTLSTAT_BRST_STAT__M, FLCTL_RDBRST_CTLSTAT_MEM_TYPE__0, FLCTL_RDBRST_CTLSTAT_MEM_TYPE__1, and FLCTL_RDBRST_CTLSTAT_MEM_TYPE__M.
Referenced by FlashCtl_eraseSector(), and FlashCtl_performMassErase().
bool FlashCtl_performMassErase |
( |
bool |
verify | ) |
|
Performs a mass erase on all unprotected flash sectors. Protected sectors are ignored.
- Parameters
-
verify | specified is verification should be turned on for erase |
- Note
- This function is blocking and will not exit until operation has either completed or failed due to an error.
- Returns
- true if mass erase completes successfully, false otherwise
References __FLASH_START__, __INFO_FLASH_START__, FLASH_1_PATTERN, FLASH_BANK0, FLASH_BANK1, FLASH_ERASE_VERIFY_READ_MODE, FLASH_NORMAL_READ_MODE, FlashCtl_getWaitState(), FlashCtl_setReadMode(), FlashCtl_setWaitState(), FlashCtl_verifyMemory(), FLCTL_ERASE_CTLSTAT_STATUS__1, FLCTL_ERASE_CTLSTAT_STATUS__2, FLCTL_ERASE_CTLSTAT_STATUS__M, and SysCtl_getFlashSize().
bool FlashCtl_eraseSector |
( |
uint32_t |
addr, |
|
|
bool |
verify |
|
) |
| |
Erases a sector of MAIN or INFO flash memory.
- Parameters
-
addr | The start of the sector to erase. Note that with flash, the minimum allowed size that can be erased is a flash sector (which is 4KB on the MSP432 family). If an address is provided to this function which is not on a 4KB boundary, the entire sector will still be erased. |
verify | specified is verification should be turned on for erase |
Note that this function is blocking and will not exit until operation has either completed or failed due to an error.
- Returns
- true if sector erase is successful, false otherwise.
References __FLASH_END__, __FLASH_START__, __INFO_FLASH_START__, FLASH_1_PATTERN, FLASH_BRSTRDCMP_COMPLETE, FLASH_ERASE_COMPLETE, FLASH_ERASE_VERIFY_READ_MODE, FLASH_INFO_SPACE, FLASH_MAIN_SPACE, FLASH_NORMAL_READ_MODE, FlashCtl_getWaitState(), FlashCtl_setReadMode(), FlashCtl_setWaitState(), FlashCtl_verifyMemory(), FLCTL_ERASE_CTLSTAT_STATUS__1, FLCTL_ERASE_CTLSTAT_STATUS__2, FLCTL_ERASE_CTLSTAT_STATUS__M, FLCTL_ERASE_CTLSTAT_TYPE__0, FLCTL_ERASE_CTLSTAT_TYPE__1, and FLCTL_ERASE_CTLSTAT_TYPE__M.
bool FlashCtl_programMemory |
( |
void * |
src, |
|
|
void * |
dest, |
|
|
uint32_t |
length, |
|
|
uint32_t |
verify |
|
) |
| |
Program a portion of flash memory with the provided data
- Parameters
-
src | Pointer to the data source to program into flash |
dest | Pointer to the destination in flash to program |
length | Length in bytes to program |
verificationSetting | Verification setting to set. This value can be a bitwise OR of the following values:
- FLASH_BURSTPOST,
- FLASH_BURSTPRE,
- FLASH_REGPRE,
- FLASH_REGPOST
- FLASH_NOVER No verification enabled
- FLASH_FULLVER Full verification enabled
|
- Note
- There are no sector/boundary restrictions for this function, however it is encouraged to proved a start address aligned on 32-bit boundaries. Providing an unaligned address will result in unaligned data accesses and detriment efficiency.
Note that this function is blocking and will not exit until operation has either completed or failed due to an error.
- Returns
- Whether or not the program succeeded
References __FLASH_END__, __FLASH_START__, __FLCTL_BASE__, __INFO_FLASH_START__, ASSERT, FLASH_BURST_PRG_BIT, FLASH_BURSTPOST, FLASH_BURSTPRE, FLASH_COLLATED_WRITE_MODE, FLASH_IMMEDIATE_WRITE_MODE, FLASH_POSTVERIFY_FAILED, FLASH_PREVERIFY_FAILED, FLASH_PRGBRSTCTLSTAT_BURSTSTATUS_COMPLETE, FLASH_PROGRAM_ERROR, FLASH_REGPOST, FLASH_REGPRE, FLASH_WRDPRGM_COMPLETE, FlashCtl_clearInterruptFlag(), FlashCtl_clearProgramVerification(), FlashCtl_disableWordProgramming(), FlashCtl_enableWordProgramming(), FlashCtl_getInterruptStatus(), FlashCtl_setProgramVerification(), FLCTL_PRGBRST_CTLSTAT_BURST_STATUS__M, FLCTL_PRGBRST_CTLSTAT_LEN__M, FLCTL_PRGBRST_CTLSTAT_TYPE__0, FLCTL_PRGBRST_CTLSTAT_TYPE__1, and FLCTL_PRGBRST_CTLSTAT_TYPE__M.
void FlashCtl_setProgramVerification |
( |
uint32_t |
verificationSetting | ) |
|
Setups pre/post verification of burst and regular flash programming instructions.
- Parameters
-
verificationSetting | Verification setting to set. This value can be a bitwise OR of the following values:
- FLASH_BURSTPOST,
- FLASH_BURSTPRE,
- FLASH_REGPRE,
- FLASH_REGPOST
- FLASH_NOVER No verification enabled
- FLASH_FULLVER Full verification enabled
|
- Returns
- none
References FLASH_BURSTPOST, FLASH_BURSTPRE, FLASH_REGPOST, and FLASH_REGPRE.
Referenced by FlashCtl_programMemory().
void FlashCtl_clearProgramVerification |
( |
uint32_t |
verificationSetting | ) |
|
Clears pre/post verification of burst and regular flash programming instructions.
- Parameters
-
verificationSetting | Verification setting to clear. This value can be a bitwise OR of the following values:
- FLASH_BURSTPOST,
- FLASH_BURSTPRE,
- FLASH_REGPRE,
- FLASH_REGPOST
- FLASH_NOVER No verification enabled
- FLASH_FULLVER Full verification enabled
|
- Returns
- none
References FLASH_BURSTPOST, FLASH_BURSTPRE, FLASH_REGPOST, and FLASH_REGPRE.
Referenced by FlashCtl_programMemory().
void FlashCtl_enableWordProgramming |
( |
uint32_t |
mode | ) |
|
Enables word programming of flash memory.
This function will enable word programming of the flash memory and set the mode of behavior when the flash write occurs.
- Parameters
-
mode | The mode specifies the behavior of the flash controller when programming words to flash. In FLASH_IMMEDIATE_WRITE_MODE, the program operation happens immediately on the write to flash while in FLASH_COLLATED_WRITE_MODE the write will be delayed until a full 128-bits have been collated. Possible values include:
- FLASH_IMMEDIATE_WRITE_MODE
- FLASH_COLLATED_WRITE_MODE
|
Refer to the user's guide for further documentation.
- Returns
- none
References FLASH_COLLATED_WRITE_MODE, and FLASH_IMMEDIATE_WRITE_MODE.
Referenced by FlashCtl_programMemory().
void FlashCtl_disableWordProgramming |
( |
void |
| ) |
|
Disables word programming of flash memory.
Refer to FlashCtl_enableWordProgramming and the user's guide for description on the difference between full word and immediate programming
- Returns
- None.
Referenced by FlashCtl_programMemory().
uint32_t FlashCtl_isWordProgrammingEnabled |
( |
void |
| ) |
|
Returns if word programming mode is enabled (and if it is, the specific mode)
Refer to FlashCtl_enableWordProgramming and the user's guide for description on the difference between full word and immediate programming
- Returns
- a zero value if word programming is disabled,
- FLASH_IMMEDIATE_WRITE_MODE
- FLASH_COLLATED_WRITE_MODE
References FLASH_COLLATED_WRITE_MODE, and FLASH_IMMEDIATE_WRITE_MODE.
bool FlashCtl_setReadMode |
( |
uint32_t |
flashBank, |
|
|
uint32_t |
readMode |
|
) |
| |
Sets the flash read mode to be used by default flash read operations. Note that the proper wait states must be set prior to entering this function.
- Parameters
-
flashBank | Flash bank to set read mode for. Valid values are:
|
readMode | The read mode to set. Valid values are:
- FLASH_NORMAL_READ_MODE,
- FLASH_MARGIN0_READ_MODE,
- FLASH_MARGIN1_READ_MODE,
- FLASH_PROGRAM_VERIFY_READ_MODE,
- FLASH_ERASE_VERIFY_READ_MODE,
- FLASH_LEAKAGE_VERIFY_READ_MODE,
- FLASH_MARGIN0B_READ_MODE,
- FLASH_MARGIN1B_READ_MODE
|
- Returns
- None.
References ASSERT, FLASH_BANK0, FLASH_BANK1, FLCTL_RDCTL_BNK0_RD_MODE__M, and FLCTL_RDCTL_BNK1_RD_MODE__M.
Referenced by FlashCtl_eraseSector(), and FlashCtl_performMassErase().
uint32_t FlashCtl_getReadMode |
( |
uint32_t |
flashBank | ) |
|
Gets the flash read mode to be used by default flash read operations.
- Parameters
-
flashBank | Flash bank to set read mode for. Valid values are:
|
- Returns
- Returns the read mode to set. Valid values are:
- FLASH_NORMAL_READ_MODE,
- FLASH_MARGIN0_READ_MODE,
- FLASH_MARGIN1_READ_MODE,
- FLASH_PROGRAM_VERIFY_READ_MODE,
- FLASH_ERASE_VERIFY_READ_MODE,
- FLASH_LEAKAGE_VERIFY_READ_MODE,
- FLASH_MARGIN0B_READ_MODE,
- FLASH_MARGIN1B_READ_MODE
References ASSERT, FLASH_BANK0, and FLASH_BANK1.
void FlashCtl_setWaitState |
( |
uint32_t |
bank, |
|
|
uint32_t |
waitState |
|
) |
| |
uint32_t FlashCtl_getWaitState |
( |
uint32_t |
bank | ) |
|
void FlashCtl_enableInterrupt |
( |
uint32_t |
flags | ) |
|
Enables individual flash control interrupt sources.
- Parameters
-
flags | is a bit mask of the interrupt sources to be enabled. Must be a logical OR of:
- FLASH_PROGRAM_ERROR,
- FLASH_BENCHMARK_INT,
- FLASH_BANK1_PARITY_ERROR,
- FLASH_BANK0_PARITY_ERROR,
- FLASH_ERASE_COMPLETE,
- FLASH_BRSTPRGM_COMPLETE,
- FLASH_WRDPRGM_COMPLETE,
- FLASH_POSTVERIFY_FAILED,
- FLASH_PREVERIFY_FAILED,
- FLASH_BRSTRDCMP_COMPLETE
|
This function enables the indicated flash system interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.
- Note
- The interrupt sources vary based on the part in use. Please consult the data sheet for the part you are using to determine which interrupt sources are available.
- Returns
- None.
void FlashCtl_disableInterrupt |
( |
uint32_t |
flags | ) |
|
Disables individual flash system interrupt sources.
- Parameters
-
flags | is a bit mask of the interrupt sources to be disabled. Must be a logical OR of:
- FLASH_PROGRAM_ERROR,
- FLASH_BENCHMARK_INT,
- FLASH_BANK1_PARITY_ERROR,
- FLASH_BANK0_PARITY_ERROR,
- FLASH_ERASE_COMPLETE,
- FLASH_BRSTPRGM_COMPLETE,
- FLASH_WRDPRGM_COMPLETE,
- FLASH_POSTVERIFY_FAILED,
- FLASH_PREVERIFY_FAILED,
- FLASH_BRSTRDCMP_COMPLETE
|
This function disables the indicated flash system interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.
- Returns
- None.
uint32_t FlashCtl_getEnabledInterruptStatus |
( |
void |
| ) |
|
Gets the current interrupt status masked with the enabled interrupts. This function is useful to call in ISRs to get a list of pending interrupts that are actually enabled and could have caused the ISR.
- Returns
- The current interrupt status, enumerated as a bit field of
- FLASH_PROGRAM_ERROR,
- FLASH_BENCHMARK_INT,
- FLASH_BANK1_PARITY_ERROR,
- FLASH_BANK0_PARITY_ERROR,
- FLASH_ERASE_COMPLETE,
- FLASH_BRSTPRGM_COMPLETE,
- FLASH_WRDPRGM_COMPLETE,
- FLASH_POSTVERIFY_FAILED,
- FLASH_PREVERIFY_FAILED,
- FLASH_BRSTRDCMP_COMPLETE
- Note
- The interrupt sources vary based on the part in use. Please consult the data sheet for the part you are using to determine which interrupt sources are available.
References FlashCtl_getInterruptStatus().
uint32_t FlashCtl_getInterruptStatus |
( |
void |
| ) |
|
Gets the current interrupt status.
- Returns
- The current interrupt status, enumerated as a bit field of:
- FLASH_PROGRAM_ERROR,
- FLASH_BENCHMARK_INT,
- FLASH_BANK1_PARITY_ERROR,
- FLASH_BANK0_PARITY_ERROR,
- FLASH_ERASE_COMPLETE,
- FLASH_BRSTPRGM_COMPLETE,
- FLASH_WRDPRGM_COMPLETE,
- FLASH_POSTVERIFY_FAILED,
- FLASH_PREVERIFY_FAILED,
- FLASH_BRSTRDCMP_COMPLETE
- Note
- The interrupt sources vary based on the part in use. Please consult the data sheet for the part you are using to determine which interrupt sources are available.
Referenced by FlashCtl_getEnabledInterruptStatus(), and FlashCtl_programMemory().
void FlashCtl_clearInterruptFlag |
( |
uint32_t |
flags | ) |
|
Clears flash system interrupt sources.
- Parameters
-
flags | is a bit mask of the interrupt sources to be cleared. Must be a logical OR of:
- FLASH_PROGRAM_ERROR,
- FLASH_BENCHMARK_INT,
- FLASH_BANK1_PARITY_ERROR,
- FLASH_BANK0_PARITY_ERROR,
- FLASH_ERASE_COMPLETE,
- FLASH_BRSTPRGM_COMPLETE,
- FLASH_WRDPRGM_COMPLETE,
- FLASH_POSTVERIFY_FAILED,
- FLASH_PREVERIFY_FAILED,
- FLASH_BRSTRDCMP_COMPLETE
|
The specified flash system interrupt sources are cleared, so that they no longer assert. This function must be called in the interrupt handler to keep it from being called again immediately upon exit.
- Note
- Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
-
The interrupt sources vary based on the part in use. Please consult the data sheet for the part you are using to determine which interrupt sources are available.
- Returns
- None.
Referenced by FlashCtl_programMemory().
void FlashCtl_registerInterrupt |
( |
void(*)(void) |
intHandler | ) |
|
Registers an interrupt handler for flash clock system interrupt.
- Parameters
-
intHandler | is a pointer to the function to be called when the clock system interrupt occurs. |
This function registers the handler to be called when a clock system interrupt occurs. This function enables the global interrupt in the interrupt controller; specific flash controller interrupts must be enabled via FlashCtl_enableInterrupt(). It is the interrupt handler's responsibility to clear the interrupt source via FlashCtl_clearInterruptFlag().
- See also
- Interrupt_registerInterrupt() for important information about registering interrupt handlers.
- Returns
- None.
References Interrupt_enableInterrupt(), and Interrupt_registerInterrupt().
void FlashCtl_unregisterInterrupt |
( |
void |
| ) |
|
Unregisters the interrupt handler for the flash system.
This function unregisters the handler to be called when a clock system interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called.
- See also
- Interrupt_registerInterrupt() for important information about registering interrupt handlers.
- Returns
- None.
References Interrupt_disableInterrupt(), and Interrupt_unregisterInterrupt().