Macros | Functions
FlashCtl

Module for erasing, programming, verifying and configuring different functionalities of the Flash IP. More...

Macros

#define FLASH_BURST_PRG_BIT   0x03
 
#define FLASH_PROGRAM_ERROR   FLCTL_IFG_PRG_ERR
 
#define FLASH_BENCHMARK_INT   FLCTL_IFG_BMRK
 
#define FLASH_ERASE_COMPLETE   FLCTL_IFG_ERASE
 
#define FLASH_BRSTPRGM_COMPLETE   FLCTL_IFG_PRGB
 
#define FLASH_WRDPRGM_COMPLETE   FLCTL_IFG_PRG
 
#define FLASH_POSTVERIFY_FAILED   FLCTL_IFG_AVPST
 
#define FLASH_PREVERIFY_FAILED   FLCTL_IFG_AVPRE
 
#define FLASH_BRSTRDCMP_COMPLETE   FLCTL_IFG_RDBRST
 
#define FLASH_NORMAL_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_0
 
#define FLASH_MARGIN0_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_1
 
#define FLASH_MARGIN1_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_2
 
#define FLASH_PROGRAM_VERIFY_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_3
 
#define FLASH_ERASE_VERIFY_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_4
 
#define FLASH_LEAKAGE_VERIFY_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_5
 
#define FLASH_MARGIN0B_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_9
 
#define FLASH_MARGIN1B_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_10
 
#define FLASH_PRGBRSTCTLSTAT_BURSTSTATUS_COMPLETE   FLCTL_PRGBRST_CTLSTAT_BURST_STATUS_7
 
#define FLASH_BANK0   0x00
 
#define FLASH_BANK1   0x01
 
#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_MAIN_SPACE   FLCTL_RDBRST_CTLSTAT_MEM_TYPE_0
 
#define FLASH_INFO_SPACE   FLCTL_RDBRST_CTLSTAT_MEM_TYPE_1
 
#define FLASH_1_PATTERN   FLCTL_RDBRST_CTLSTAT_DATA_CMP
 
#define FLASH_0_PATTERN   0x00
 
#define FLASH_SECTOR0   FLCTL_BANK0_MAIN_WEPROT_PROT0
 
#define FLASH_SECTOR1   FLCTL_BANK0_MAIN_WEPROT_PROT1
 
#define FLASH_SECTOR2   FLCTL_BANK0_MAIN_WEPROT_PROT2
 
#define FLASH_SECTOR3   FLCTL_BANK0_MAIN_WEPROT_PROT3
 
#define FLASH_SECTOR4   FLCTL_BANK0_MAIN_WEPROT_PROT4
 
#define FLASH_SECTOR5   FLCTL_BANK0_MAIN_WEPROT_PROT5
 
#define FLASH_SECTOR6   FLCTL_BANK0_MAIN_WEPROT_PROT6
 
#define FLASH_SECTOR7   FLCTL_BANK0_MAIN_WEPROT_PROT7
 
#define FLASH_SECTOR8   FLCTL_BANK0_MAIN_WEPROT_PROT8
 
#define FLASH_SECTOR9   FLCTL_BANK0_MAIN_WEPROT_PROT9
 
#define FLASH_SECTOR10   FLCTL_BANK0_MAIN_WEPROT_PROT10
 
#define FLASH_SECTOR11   FLCTL_BANK0_MAIN_WEPROT_PROT11
 
#define FLASH_SECTOR12   FLCTL_BANK0_MAIN_WEPROT_PROT12
 
#define FLASH_SECTOR13   FLCTL_BANK0_MAIN_WEPROT_PROT13
 
#define FLASH_SECTOR14   FLCTL_BANK0_MAIN_WEPROT_PROT14
 
#define FLASH_SECTOR15   FLCTL_BANK0_MAIN_WEPROT_PROT15
 
#define FLASH_SECTOR16   FLCTL_BANK0_MAIN_WEPROT_PROT16
 
#define FLASH_SECTOR17   FLCTL_BANK0_MAIN_WEPROT_PROT17
 
#define FLASH_SECTOR18   FLCTL_BANK0_MAIN_WEPROT_PROT18
 
#define FLASH_SECTOR19   FLCTL_BANK0_MAIN_WEPROT_PROT19
 
#define FLASH_SECTOR20   FLCTL_BANK0_MAIN_WEPROT_PROT20
 
#define FLASH_SECTOR21   FLCTL_BANK0_MAIN_WEPROT_PROT21
 
#define FLASH_SECTOR22   FLCTL_BANK0_MAIN_WEPROT_PROT22
 
#define FLASH_SECTOR23   FLCTL_BANK0_MAIN_WEPROT_PROT23
 
#define FLASH_SECTOR24   FLCTL_BANK0_MAIN_WEPROT_PROT24
 
#define FLASH_SECTOR25   FLCTL_BANK0_MAIN_WEPROT_PROT25
 
#define FLASH_SECTOR26   FLCTL_BANK0_MAIN_WEPROT_PROT26
 
#define FLASH_SECTOR27   FLCTL_BANK0_MAIN_WEPROT_PROT27
 
#define FLASH_SECTOR28   FLCTL_BANK0_MAIN_WEPROT_PROT28
 
#define FLASH_SECTOR29   FLCTL_BANK0_MAIN_WEPROT_PROT29
 
#define FLASH_SECTOR30   FLCTL_BANK0_MAIN_WEPROT_PROT30
 
#define FLASH_SECTOR31   FLCTL_BANK0_MAIN_WEPROT_PROT31
 
#define FLASH_NOVER   0
 
#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
 
#define FLASH_FULLVER
 
#define FLASH_COLLATED_WRITE_MODE   0x01
 
#define FLASH_IMMEDIATE_WRITE_MODE   0x02
 
#define __INFO_FLASH_TECH_START__   0x00200000
 
#define __INFO_FLASH_TECH_MIDDLE__   0x00202000
 

Functions

void FlashCtl_getMemoryInfo (uint32_t addr, uint32_t *bankNum, uint32_t *sectorNum)
 
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 (void)
 
void FlashCtl_initiateMassErase (void)
 
bool FlashCtl_eraseSector (uint32_t addr)
 
bool FlashCtl_programMemory (void *src, void *dest, uint32_t length)
 
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)
 
void FlashCtl_initiateSectorErase (uint32_t addr)
 
uint8_t __FlashCtl_remaskData8Post (uint8_t data, uint32_t addr)
 
uint8_t __FlashCtl_remaskData8Pre (uint8_t data, uint32_t addr)
 
uint32_t __FlashCtl_remaskData32Post (uint32_t data, uint32_t addr)
 
uint32_t __FlashCtl_remaskData32Pre (uint32_t data, uint32_t addr)
 
void __FlashCtl_remaskBurstDataPost (uint32_t addr, uint32_t size)
 
void __FlashCtl_remaskBurstDataPre (uint32_t addr, uint32_t size)
 

Detailed Description

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.


Flash Controller Limitations


When utilizing the flash controller for MSP432, the user program has to take special consideration on a few critical limitations. The biggest obstacle that the user has to be mindful of is the stringent verification requirements imposed by the flash controller. Many operations (such as program and verify) will take multiple cycles to complete successfully and the usage is somewhat complicated for a normal user program. For this reason, it is strongly recommended that the user uses the DriverLib APIs for programming and erasing flash. Using the flash controller directly is strongly discouraged as the level of overhead and attention to verification requirements make for a very intricate user experience.

Furthermore, when using the FlashCtl APIs, the user must take special consideration of where the API is being executed. For the critical APIs (such as erase and program), the DriverLib APIs are required to be executed from either SRAM or ROM (using the ROM_ prefix). Due to the verification requirements of the flash controller, running these APIs out of Flash is not currently supported.


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 the DriverLib APIs, the wait states are automatically changed within the API.

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 SDK 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:

Macro Definition Documentation

#define FLASH_BURST_PRG_BIT   0x03
#define FLASH_PROGRAM_ERROR   FLCTL_IFG_PRG_ERR
#define FLASH_BENCHMARK_INT   FLCTL_IFG_BMRK
#define FLASH_ERASE_COMPLETE   FLCTL_IFG_ERASE
#define FLASH_BRSTPRGM_COMPLETE   FLCTL_IFG_PRGB
#define FLASH_WRDPRGM_COMPLETE   FLCTL_IFG_PRG
#define FLASH_POSTVERIFY_FAILED   FLCTL_IFG_AVPST
#define FLASH_PREVERIFY_FAILED   FLCTL_IFG_AVPRE
#define FLASH_BRSTRDCMP_COMPLETE   FLCTL_IFG_RDBRST
#define FLASH_NORMAL_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_0
#define FLASH_MARGIN0_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_1
#define FLASH_MARGIN1_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_2
#define FLASH_PROGRAM_VERIFY_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_3
#define FLASH_ERASE_VERIFY_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_4

Referenced by FlashCtl_verifyMemory().

#define FLASH_LEAKAGE_VERIFY_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_5
#define FLASH_MARGIN0B_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_9
#define FLASH_MARGIN1B_READ_MODE   FLCTL_BANK0_RDCTL_RD_MODE_10
#define FLASH_PRGBRSTCTLSTAT_BURSTSTATUS_COMPLETE   FLCTL_PRGBRST_CTLSTAT_BURST_STATUS_7
#define FLASH_BANK0   0x00
#define FLASH_BANK1   0x01
#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_MAIN_SPACE   FLCTL_RDBRST_CTLSTAT_MEM_TYPE_0
#define FLASH_INFO_SPACE   FLCTL_RDBRST_CTLSTAT_MEM_TYPE_1
#define FLASH_1_PATTERN   FLCTL_RDBRST_CTLSTAT_DATA_CMP
#define FLASH_0_PATTERN   0x00

Referenced by FlashCtl_verifyMemory().

#define FLASH_SECTOR0   FLCTL_BANK0_MAIN_WEPROT_PROT0
#define FLASH_SECTOR1   FLCTL_BANK0_MAIN_WEPROT_PROT1
#define FLASH_SECTOR2   FLCTL_BANK0_MAIN_WEPROT_PROT2
#define FLASH_SECTOR3   FLCTL_BANK0_MAIN_WEPROT_PROT3
#define FLASH_SECTOR4   FLCTL_BANK0_MAIN_WEPROT_PROT4
#define FLASH_SECTOR5   FLCTL_BANK0_MAIN_WEPROT_PROT5
#define FLASH_SECTOR6   FLCTL_BANK0_MAIN_WEPROT_PROT6
#define FLASH_SECTOR7   FLCTL_BANK0_MAIN_WEPROT_PROT7
#define FLASH_SECTOR8   FLCTL_BANK0_MAIN_WEPROT_PROT8
#define FLASH_SECTOR9   FLCTL_BANK0_MAIN_WEPROT_PROT9
#define FLASH_SECTOR10   FLCTL_BANK0_MAIN_WEPROT_PROT10
#define FLASH_SECTOR11   FLCTL_BANK0_MAIN_WEPROT_PROT11
#define FLASH_SECTOR12   FLCTL_BANK0_MAIN_WEPROT_PROT12
#define FLASH_SECTOR13   FLCTL_BANK0_MAIN_WEPROT_PROT13
#define FLASH_SECTOR14   FLCTL_BANK0_MAIN_WEPROT_PROT14
#define FLASH_SECTOR15   FLCTL_BANK0_MAIN_WEPROT_PROT15
#define FLASH_SECTOR16   FLCTL_BANK0_MAIN_WEPROT_PROT16
#define FLASH_SECTOR17   FLCTL_BANK0_MAIN_WEPROT_PROT17
#define FLASH_SECTOR18   FLCTL_BANK0_MAIN_WEPROT_PROT18
#define FLASH_SECTOR19   FLCTL_BANK0_MAIN_WEPROT_PROT19
#define FLASH_SECTOR20   FLCTL_BANK0_MAIN_WEPROT_PROT20
#define FLASH_SECTOR21   FLCTL_BANK0_MAIN_WEPROT_PROT21
#define FLASH_SECTOR22   FLCTL_BANK0_MAIN_WEPROT_PROT22
#define FLASH_SECTOR23   FLCTL_BANK0_MAIN_WEPROT_PROT23
#define FLASH_SECTOR24   FLCTL_BANK0_MAIN_WEPROT_PROT24
#define FLASH_SECTOR25   FLCTL_BANK0_MAIN_WEPROT_PROT25
#define FLASH_SECTOR26   FLCTL_BANK0_MAIN_WEPROT_PROT26
#define FLASH_SECTOR27   FLCTL_BANK0_MAIN_WEPROT_PROT27
#define FLASH_SECTOR28   FLCTL_BANK0_MAIN_WEPROT_PROT28
#define FLASH_SECTOR29   FLCTL_BANK0_MAIN_WEPROT_PROT29
#define FLASH_SECTOR30   FLCTL_BANK0_MAIN_WEPROT_PROT30
#define FLASH_SECTOR31   FLCTL_BANK0_MAIN_WEPROT_PROT31
#define FLASH_NOVER   0
#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
#define FLASH_FULLVER
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
#define __INFO_FLASH_TECH_START__   0x00200000
#define __INFO_FLASH_TECH_MIDDLE__   0x00202000

Function Documentation

void FlashCtl_getMemoryInfo ( uint32_t  addr,
uint32_t *  bankNum,
uint32_t *  sectorNum 
)

Calculates the flash bank and sector number given an address. Stores the results into the two pointers given as parameters. The user must provide a valid memory address (an address in SRAM for example will give an invalid result).

Parameters
addrAddress to calculate the bank/sector information for
bankNumThe bank number will be stored in here after the function completes.
sectorNumThe sector number will be stored in here after the function completes.
Note
For simplicity, this API only works with address in MAIN flash memory. For calculating the sector/bank number of an address in info memory, please refer to your device datasheet/
Returns
None.

References FLASH_BANK0, FLASH_BANK1, and SysCtl_getFlashSize().

void FlashCtl_enableReadBuffering ( uint_fast8_t  memoryBank,
uint_fast8_t  accessMethod 
)

Enables read buffering on accesses to a specified bank of flash memory

Parameters
memoryBankis the value of the memory bank to enable read buffering. Must be only one of the following values:
  • FLASH_BANK0,
  • FLASH_BANK1
accessMethodis 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
memoryBankis the value of the memory bank to disable read buffering. Must be only one of the following values:
  • FLASH_BANK0,
  • FLASH_BANK1
accessMethodis 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
memorySpaceis 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
sectorMaskis 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.
Not all devices will contain a dedicated INFO memory. Please check the device datasheet to see if your device has INFO memory available for use. For devices without INFO memory, any operation related to the INFO memory will be ignored by the hardware.
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
memorySpaceis 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
sectorMaskis 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.
Not all devices will contain a dedicated INFO memory. Please check the device datasheet to see if your device has INFO memory available for use. For devices without INFO memory, any operation related to the INFO memory will be ignored by the hardware.
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
memorySpaceis 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
sectoris 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.

Note
Not all devices will contain a dedicated INFO memory. Please check the device datasheet to see if your device has INFO memory available for use. For devices without INFO memory, any operation related to the INFO memory will be ignored by the hardware.
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
verifyAddrStart address where verification will begin
lengthLength in bytes to verify based off the pattern
patternThe 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
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.
This function is blocking and will not exit until operation has either completed or failed due to an error. Furthermore, given the complex verification requirements of the flash controller, master interrupts are disabled throughout execution of this function. The original interrupt context is saved at the start of execution and restored prior to exit of the API.
Due to the hardware limitations of the flash controller, this function cannot verify a memory address in the same flash bank that it is executing from. If using the ROM version of this API (by using the (ROM_ or MAP_ prefixes) this is a don't care, however if this API resides in flash then special care needs to be taken to ensure no code execution or reads happen in the flash bank being programmed while this API is being executed.
Returns
true if memory verification is successful, false otherwise.

References __INFO_FLASH_TECH_MIDDLE__, __INFO_FLASH_TECH_START__, ASSERT, CPU_primask(), FLASH_0_PATTERN, FLASH_1_PATTERN, FLASH_BANK0, FLASH_BANK1, FLASH_ERASE_VERIFY_READ_MODE, FLASH_INFO_SPACE, FLASH_MAIN_SPACE, FLASH_PROGRAM_VERIFY_READ_MODE, FlashCtl_getReadMode(), FlashCtl_getWaitState(), FlashCtl_setReadMode(), FlashCtl_setWaitState(), HWREG32, HWREG8, Interrupt_disableMaster(), Interrupt_enableMaster(), and SysCtl_getFlashSize().

Referenced by FlashCtl_eraseSector(), and FlashCtl_performMassErase().

bool FlashCtl_performMassErase ( void  )

Performs a mass erase on all unprotected flash sectors. Protected sectors are ignored.

Note
This function is blocking and will not exit until operation has either completed or failed due to an error. Furthermore, given the complex verification requirements of the flash controller, master interrupts are disabled throughout execution of this function. The original interrupt context is saved at the start of execution and restored prior to exit of the API.
Due to the hardware limitations of the flash controller, this function cannot erase a memory address in the same flash bank that it is executing from. If using the ROM version of this API (by using the (ROM_ or MAP_ prefixes) this is a don't care, however if this API resides in flash then special care needs to be taken to ensure no code execution or reads happen in the flash bank being programmed while this API is being executed.
Returns
true if mass erase completes successfully, false otherwise

References __INFO_FLASH_TECH_START__, CPU_primask(), FLASH_1_PATTERN, FlashCtl_eraseSector(), FlashCtl_verifyMemory(), Interrupt_disableMaster(), Interrupt_enableMaster(), and SysCtl_getFlashSize().

void FlashCtl_initiateMassErase ( void  )

Initiates a mass erase and returns control back to the program. This is a non-blocking function, however it is the user's responsibility to perform the necessary verification requirements after the interrupt is set to signify completion.

Returns
None
bool FlashCtl_eraseSector ( uint32_t  addr)

Erases a sector of MAIN or INFO flash memory.

Parameters
addrThe 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.
Note
This function is blocking and will not exit until operation has either completed or failed due to an error. Furthermore, given the complex verification requirements of the flash controller, master interrupts are disabled throughout execution of this function. The original interrupt context is saved at the start of execution and restored prior to exit of the API.
Due to the hardware limitations of the flash controller, this function cannot erase a memory addressin the same flash bank that it is executing from. If using the ROM version of this API (by using the (ROM_ or MAP_ prefixes) this is a don't care, however if this API resides in flash then special care needs to be taken to ensure no code execution or reads happen in the flash bank being programmed while this API is being executed.
Returns
true if sector erase is successful, false otherwise.

References __INFO_FLASH_TECH_START__, CPU_primask(), FLASH_1_PATTERN, FLASH_INFO_SPACE, FLASH_MAIN_SPACE, FlashCtl_verifyMemory(), Interrupt_disableMaster(), Interrupt_enableMaster(), SysCtl_FlashTLV_Info::maxErasePulses, SysCtl_getFlashSize(), SysCtl_getTLVInfo(), and TLV_TAG_FLASHCTL.

Referenced by FlashCtl_performMassErase().

bool FlashCtl_programMemory ( void *  src,
void *  dest,
uint32_t  length 
)

Program a portion of flash memory with the provided data

Parameters
srcPointer to the data source to program into flash
destPointer to the destination in flash to program
lengthLength in bytes to program
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.
This function is blocking and will not exit until operation has either completed or failed due to an error. Furthermore, given the complex verification requirements of the flash controller, master interrupts are disabled throughout execution of this function. The original interrupt context is saved at the start of execution and restored prior to exit of the API.
Due to the hardware limitations of the flash controller, this function cannot program a memory addressin the same flash bank that it is executing from. If using the ROM version of this API (by using the (ROM_ or MAP_ prefixes) this is a don't care, however if this API resides in flash then special care needs to be taken to ensure no code execution or reads happen in the flash bank being programmed while this API is being executed.
Returns
Whether or not the program succeeded

References CPU_primask(), FLASH_IMMEDIATE_WRITE_MODE, FlashCtl_disableWordProgramming(), FlashCtl_enableWordProgramming(), Interrupt_disableMaster(), Interrupt_enableMaster(), SysCtl_FlashTLV_Info::maxProgramPulses, SysCtl_getTLVInfo(), and TLV_TAG_FLASHCTL.

void FlashCtl_setProgramVerification ( uint32_t  verificationSetting)

Setups pre/post verification of burst and regular flash programming instructions. Note that this API is for advanced users that are programming their own flash drivers. The program/erase APIs are not affected by this setting and take care of the verification requirements.

Parameters
verificationSettingVerification 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.

void FlashCtl_clearProgramVerification ( uint32_t  verificationSetting)

Clears pre/post verification of burst and regular flash programming instructions. Note that this API is for advanced users that are programming their own flash drivers. The program/erase APIs are not affected by this setting and take care of the verification requirements.

Parameters
verificationSettingVerification 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.

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
modeThe 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
flashBankFlash bank to set read mode for. Valid values are:
  • FLASH_BANK0
  • FLASH_BANK1
readModeThe 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, and FLASH_BANK1.

Referenced by __FlashCtl_remaskBurstDataPost(), __FlashCtl_remaskBurstDataPre(), __FlashCtl_remaskData32Post(), __FlashCtl_remaskData32Pre(), __FlashCtl_remaskData8Post(), __FlashCtl_remaskData8Pre(), and FlashCtl_verifyMemory().

uint32_t FlashCtl_getReadMode ( uint32_t  flashBank)

Gets the flash read mode to be used by default flash read operations.

Parameters
flashBankFlash bank to set read mode for. Valid values are:
  • FLASH_BANK0
  • FLASH_BANK1
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.

Referenced by __FlashCtl_remaskBurstDataPost(), __FlashCtl_remaskBurstDataPre(), __FlashCtl_remaskData32Post(), __FlashCtl_remaskData32Pre(), __FlashCtl_remaskData8Post(), __FlashCtl_remaskData8Pre(), and FlashCtl_verifyMemory().

void FlashCtl_setWaitState ( uint32_t  bank,
uint32_t  waitState 
)

Changes the number of wait states that are used by the flash controller for read operations. When changing frequency ranges of the clock, this functions must be used in order to allow for readable flash memory.

Parameters
waitStateThe number of wait states to set. Note that only bits 0-3 are used.
flashBankFlash bank to set wait state for. Valid values are:
  • FLASH_BANK0
  • FLASH_BANK1

References ASSERT, FLASH_BANK0, and FLASH_BANK1.

Referenced by __FlashCtl_remaskBurstDataPost(), __FlashCtl_remaskBurstDataPre(), __FlashCtl_remaskData32Post(), __FlashCtl_remaskData32Pre(), __FlashCtl_remaskData8Post(), __FlashCtl_remaskData8Pre(), and FlashCtl_verifyMemory().

uint32_t FlashCtl_getWaitState ( uint32_t  bank)

Returns the set number of flash wait states for the given flash bank.

Parameters
flashBankFlash bank to set wait state for. Valid values are:
  • FLASH_BANK0
  • FLASH_BANK1
Returns
The wait state setting for the specified flash bank

References ASSERT, FLASH_BANK0, and FLASH_BANK1.

Referenced by __FlashCtl_remaskBurstDataPost(), __FlashCtl_remaskBurstDataPre(), __FlashCtl_remaskData32Post(), __FlashCtl_remaskData32Pre(), __FlashCtl_remaskData8Post(), __FlashCtl_remaskData8Pre(), and FlashCtl_verifyMemory().

void FlashCtl_enableInterrupt ( uint32_t  flags)

Enables individual flash control interrupt sources.

Parameters
flagsis a bit mask of the interrupt sources to be enabled. Must be a logical OR of:
  • FLASH_PROGRAM_ERROR,
  • FLASH_BENCHMARK_INT,
  • 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
flagsis a bit mask of the interrupt sources to be disabled. Must be a logical OR of:
  • FLASH_PROGRAM_ERROR,
  • FLASH_BENCHMARK_INT,
  • 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_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_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().

void FlashCtl_clearInterruptFlag ( uint32_t  flags)

Clears flash system interrupt sources.

Parameters
flagsis a bit mask of the interrupt sources to be cleared. Must be a logical OR of:
  • FLASH_PROGRAM_ERROR,
  • FLASH_BENCHMARK_INT,
  • 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.
void FlashCtl_registerInterrupt ( void(*)(void)  intHandler)

Registers an interrupt handler for flash clock system interrupt.

Parameters
intHandleris 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 INT_FLCTL, 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 INT_FLCTL, Interrupt_disableInterrupt(), and Interrupt_unregisterInterrupt().

void FlashCtl_initiateSectorErase ( uint32_t  addr)

Initiates a sector erase of MAIN or INFO flash memory. Note that this function simply initaites the sector erase, but does no verification which is required by the flash controller. The user must manually set and enable interrupts on the flash controller to fire on erase completion and then use the FlashCtl_verifyMemory function to verify that the sector was actually erased

Parameters
addrThe 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.
Returns
None

References __INFO_FLASH_TECH_START__, FLASH_INFO_SPACE, FLASH_MAIN_SPACE, and SysCtl_getFlashSize().

uint8_t __FlashCtl_remaskData8Post ( uint8_t  data,
uint32_t  addr 
)
uint8_t __FlashCtl_remaskData8Pre ( uint8_t  data,
uint32_t  addr 
)
uint32_t __FlashCtl_remaskData32Post ( uint32_t  data,
uint32_t  addr 
)
uint32_t __FlashCtl_remaskData32Pre ( uint32_t  data,
uint32_t  addr 
)
void __FlashCtl_remaskBurstDataPost ( uint32_t  addr,
uint32_t  size 
)
void __FlashCtl_remaskBurstDataPre ( uint32_t  addr,
uint32_t  size 
)

Copyright 2018, Texas Instruments Incorporated