PSoC® 3, PSoC 4, and PSoC 5LP Flash Memory Organization and Array ID Parameter - KBA84740

Version: *D

 

Question:

How is the flash memory organized in PSoC 3, PSoC 4, and PSoC 5LP? How do we choose the array ID parameter for the CyWriteRowData API?

 

Answer:

PSoC 3

 

In PSoC 3, the flash memory is organized as follows: (see Figure 1)

 

  1. One array of 64, 128, or 256 rows depending on the part number (Refer to the Ordering Information section of the family datasheet).
  2. Each row contains 256 data bytes plus 32 bytes for either ECC or data storage. To enable ECC in PSoC Creator, click the System tab of the .cydwr file > Configuration > Enable Error Correcting Code (ECC). If the option ‘Store Configuration Data in ECC Memory’ is enabled, then the device configuration data will be stored in the ECC memory to reduce main flash memory usage. Error correction may not be used when this option is enabled.

 

Figure 1. Flash Memory Organization for PSoC 3

 

Flash_Memory_Organization_for_PSoC3.png

 

PSoC 4

 

In PSoC 4, the flash memory is organized as follows: (see Figure 2)

 

  1. Either one array of 128, 256, or 512 rows, or two arrays of 512 rows depending on the part number (Refer to the Ordering Information section of the family datasheet).
  2. Each row contains 64, 128, or 256 data bytes depending on the part number (Refer to the Ordering Information section of the family datasheet). PSoC 4 has a maximum of 128 KB of flash memory and does not support the ECC feature.

 

Figure 2. Flash Memory Organization for PSoC 4

 

Flash_Memory_Organization_for_PSoC4.png

 

PSoC 5LP

 

In PSoC 5LP, the flash memory is organized as follows: (see Figure 3)

 

  1. Either one array of 128 or 256 rows, or as multiple arrays of 256 rows depending on the part number (Refer to the Ordering Information section of the family datasheet).
  2. Each row contains 256 data bytes plus 32 bytes for either error correcting codes (ECC) or configuration data.

 

Figure 3. Flash Memory Organization for PSoC5 LP

 

Flash_Memory_Organization_for_PSoC5_LP.png

 

Writing data into Flash Using Firmware:

 

There are three APIs to write data into flash in PSoC 3/ PSoC 5LP.

 

  1. CyWriteRowFull(uint8 arrayId, uint16 rowAddress, uint8 *rowData, uint16 rowSize): to write the entire row including ECC
  2. CyWriteRowData(uint8 arrayId, uint16 rowAddress, uint8 *rowData): to write the entire row without ECC
  3. CyWriteRowConfig(uint8 arrayId, uint16 rowAddress, uint8 *rowECC) to write just the ECC memory

 

The parameters required by these APIs are as follows:

 

  • Array-ID: The block number in which the required row is present. In the case of PSoC 3, the valid Array-ID is only 0x00
  • RowAddress: Row address within the specified arrayId
  • RowData/RowECC: Address of the data to be programmed
  • RowSize: Number of bytes of row data

 

To write data into PSoC 4 flash, we use the CySysFlashWriteRow API, which does not require the Array-ID Parameter.

 

These flash APIs are defined in the CyFlash.c file. Details of the APIs are available in the System Reference Guide, which can be located in PSoC Creator at the following path:

 

Help > Documentation > System Reference > System Reference Guide