Programming and Erasing Flash Memory by User Program For Traveo ™ Family
Programming and Erasing Flash Memory by User Program For Traveo ™ Family
Programming and Erasing Flash Memory by User Program For Traveo ™ Family
Programming and Erasing Flash Memory by User Program for Traveo™ Family
This application note describes how to program and erase the flash memory by user program for the Traveo family.
Major topics include the operation explanation of TCFLASH, the explanation of TCFLASH command and the
explanation of an example of TCFLASH reprogramming.
Contents
1 Introduction ..................................................................1 4.3 Program Command Sequence (64-bit) ............... 9
2 Overview of Flash Memory ..........................................1 4.4 Macro Erase (Chip Erase) Command Sequence
2.1 TCFLASH memory..............................................2 ............................................................................ 9
2.2 WorkFlash Memory .............................................3 4.5 Sector Erase Command Sequence .................. 10
3 TCFLASH Operation ...................................................3 5 TCFLASH Reprogramming Procedure ...................... 10
3.1 TCFLASH Operation Mode .................................3 5.1 Enable Programming ........................................ 12
3.2 Programming and Erasing TCFLASH .................3 5.2 Sector Erase Sequence .................................... 13
3.3 Command Sequence for S6J3110/S6J3120/ 5.3 Program Sequence ........................................... 14
S6J3200 ..............................................................3 6 Related Documents ................................................... 15
3.4 Command Sequence for S6J3300/S6J3350/ Document History............................................................ 16
S6J3360/S6J3370/S6J3400................................5 Worldwide Sales and Design Support ............................. 17
3.5 Automatic Algorithm Execution Status ................8 Products .......................................................................... 17
4 Command ....................................................................9 PSoC® Solutions ............................................................ 17
4.1 Reset and Read Command.................................9 Cypress Developer Community....................................... 17
4.2 Program Command Sequence............................9 Technical Support ........................................................... 17
1 Introduction
This application note describes how to program and erase the flash memory of the Traveo family. In this document,
Traveo family refers to S6J3110/S6J3120/S6J3200/S6J3300/S6J3350/S6J3360/S6J3370/S6J3400 series.
Programming with access via the AXI region has the highest priority in TCFLASH. With the default setting,
reading priority is toggled between accesses via the AXI region and accesses via the TCM region every 16 clock
cycle.
In TCFLASH, set the priority to allow reading with access via the TCM region. However, reading has a lower
priority than programming.
It is possible to read 8-bit/16-bit/32-bit/64-bit data from CPU.
ECC (Error Check and Correct) is supported only in AXI with the same calculation formula as that for the ARM
Cortex-R5F core, with 1-bit error correction and 2-bit error detection. If ECC is enabled, programming from the CPU
is possible only in 16- or 32-bit mode. If ECC is disabled, programming from the CPU is possible in 8-, 16-, or 32-bit
mode.
A TCFLASH memory is available only for the CPU core and is placed on the memory map by the program, as shown
in Figure 1.
Figure 1. Position of TCFLASH on Memory Map
Address
0x06000000
TCFLASH AXI region
0x05000000
TCM region
0x04800000
(TCRAM region)
0x04000000
0x02000000
AXI region
0x01000000
TCM region
0x00800000
(TCRAM region)
0x00000000
TCM Interface
Cortex-R5F
TCFLASH
Core
AXI AXI
3 TCFLASH Operation
3.1 TCFLASH Operation Mode
Traveo family when in user mode, the CPU or other bus masters can access the TCFLASH. A Cortex-R5F core can
access the TCFLASH that is connected to itself via the TCM or AXI interface.
Specify the values shown in Table 1 for CA1 and in Table 2 for CA0.
Specify the value of the lower 32 bits of the 64-bit program data for PD64_0 in Table 1. Specify the value of the
upper 32 bits of the 64-bit program data for PD64_1.
Except for the program data that is represented as PD, PD64_0, PD64_1 in Table 1, the upper 24 bits (bit 31 to
bit 8) of data to be programmed to start an automatic algorithm are ignored.
In Table 2, ***** is an arbitrary value that specifies the address range used by the flash memory for which the
command is executed. For the memory map, see Figure 1.
The address, PA, given in the 4th write cycle is the address in to which the program data, PD, is written.
The programming address, PA, for programming must be a value that is aligned to the programming-size.
The address SA given in the 6th program cycle of the sector erase command indicates the address of the sector
to be erased. SA is specified in the same format as PA.
The flash memory is reset and transitions to read mode if an invalid address or data set is programmed as a
command or if commands are programmed in the wrong order.
The read operation from flash memory is possible even when the command sequence is being programmed. The
automatic algorithm starts upon completion of the last cycle of the program sequence.
Do not specify the sector address for which sector protection is enabled for CA0, CA1, SA, SA0, SA1, and PA.
Do not change the setting of the sector protection register for TCFLASH (TCFCFG0_C*SWP) while writing the
command sequence.
Flash memory must not be read-accessed until the status register READ changes to “1” after the sector erase
suspend command is issued.
1st Cycle 2nd Cycle 3rd Cycle 4th Cycle 5th Cycle 6th Cycle 7th Cycle
Command
Address Data Address Data Address Data Address Data Address Data Address Data Address Data
Read RA RD – – – – – – – – – – – –
Program
CA0 0xAA CA1 0x55 CA0 0xAC PA PD64_0 any PD64_1 – – – –
(64 bit)
Macro Erase
CA0 0xAA CA1 0x55 CA0 0x80 CA0 0xAA CA1 0x55 CA0 0x10 – –
(Chip Erase)
Sector Erase CA0 0xAA CA1 0x55 CA0 0x80 CA0 0xAA CA1 0x55 SA0 0x30 – –
Multiple
CA0 0xAA CA1 0x55 CA0 0x80 CA0 0xAA CA1 0x55 SA0 0xE0 SA1 0x30
Sectors Erase
Sector Erase
SA 0xB0 – – – – – – – – – – – –
Suspend
Sector Erase
SA 0x30 – – – – – – – – – – – –
Resume
CAx: Refer to Table 2. RA: Read Address, RD: Read Data, SAx: Sector Address, PA: Program Address, PD: Program Data, PD64_0: Program Data (lower
32 bits of 64-bit program data), PD64_1: Program Data (upper 32 bits of 64-bit program data).
CA0 0x*****AA8
User mode
CA1 0x*****554
The address PA given at the 4th write cycle is the address in which program data PD is written. The commands
before the sending of PA and PD are preamble commands. The preambles have explicit addresses and data
values.
For addresses containing the "any" entry, it means that basically any valid Flash address can be used. However,
it must be ensured, that the Flash address used has not a disabled sector write permission
(TCFCFG0_CSWPx[n]=0). Otherwise the command is dropped and an error response is returned.
For the 256bit programming mode, the "nth cycle" is 7th to 11th cycle.
For the page mode, the "kth cycle" is 12th to 131st cycle.
In Table 5, ***** is an arbitrary value that specifies the address range used by the flash memory for which the
command is executed. The write permission of the given address must be set to "enabled". Therefore, it is
recommended that the resulting Flash address should fall into the target sector. For the memory map, see
Figure 1.
To allow the macro erase operation, all sector write permissions must be set to "enabled".
For the 16bit/32bit programming mode, the size of input data determines whether the programming is 16bit or
32bit mode.
For the 16bit mode, the bit1 of the address determines which half of the 32bit-word in the flash is programmed. If
bit1 is "0", the lower 16 bits of the 32-word are programmed. If bit1 is "1", the higher 16 bits are programmed.
For the 64bit/256bit/page programming mode, the PDs are written to the flash memory at addresses in an
increasing sequence.
For the 64bit/256bit/page programming mode, only the address of the first 32bit-word at cycle 4 is accepted by
the flash memory. The addresses starting from cycle 5 are ignored by the flash memory.
8-bit programming mode does not exist.
The allowed data types for the user to program the flash must be of 16 bits or 32 bits. This rule applies not only
to the programming data, but also to the preambles.
Programming the flash using burst mode is prohibited.
The programming address PA for programming must be a value which is programming size aligned.
The address SA given upon the 6th program cycle of the sector erase command indicates the address of the
sector to be erased. SA is specified in the same format as PA.
Flash memory is reset and transitions to read mode if an invalid address or data set is programmed as a
command or if commands are programmed in the wrong order.
The read operation from flash memory is possible even when the command sequence is being programmed. The
automatic algorithm starts upon completion of the last cycle of the program sequence.
Do not change the setting of the sector write permission register for TCFLASH (TCFCFG0_CSWP*) while writing
the command sequence.
Two modes of sector erase suspend exist described in the following table.
Table 3. Two Modes of Sector Erase Suspend
Flash memory must not be read-accessed until the status register READ changes to "1" after the sector erase
suspend command is issued.
The embedded algorithm operation reset command is one type of hardware reset, which terminates the
Automatic Algorithm state (Program/Macro Erase/Sector Erase) of flash and changes to Normal Command state.
In the Normal Command state, this macro accepts automatic algorithm execution commands (write) for executing
program/erase operations and read commands (read).
The "Command Reset" command resets the execution commands before the flash enters the Automatic
Algorithm state, and enables re-write the command from the beginning.
1st Cycle 2nd Cycle 3rd Cycle 4th Cycle 5th Cycle 6th Cycle nth Cycle kth Cycle
Command
Address Data Address Data Address Data Address Data Address Data Address Data Address Data Address Data
Program
CA0 0xAA CA1 0x55 CA0 0xA0 PA PD – – – – – – – –
(16bit/32bit)
Program
CA0 0xAA CA1 0x55 CA0 0xAC PA PD any PD – – – – – –
(64 bit)
Program
CA0 0xAA CA1 0x55 CA0 0xA4 PA PD any PD any PD any PD – –
(256 bit)
Page
CA0 0xAA CA1 0x55 CA0 0xA8 PA PD any PD any PD any PD any PD
Program
Macro Erase
CA0 0xAA CA1 0x55 CA0 0x80 CA0 0xAA CA1 0x55 CA0 0x10 – – – –
(Chip Erase)
Sector
CA0 0xAA CA1 0x55 CA0 0x80 CA0 0xAA CA1 0x55 SA 0x30 – – – –
Erase
Multiple
Sector CA0 0xAA CA1 0x55 CA0 0x80 CA0 0xAA CA1 0x55 SA 0xE0 SA 0xE0 SA 0x30
Erase
Sector
Erase any 0xB0 – – – – – – – – – – – – – –
suspend 1
Sector
Erase any 0xBC – – – – – – – – – – – – – –
suspend 2
Erase
any 0x30 – – – – – – – – – – – – – –
resume
Embedded
Algorithm
any 0xF4 – – – – – – – – – – – – – –
Operation
Reset
Command
any 0xF0 – – – – – – – – – – – – – –
Reset
CAx: Refer to Table 5. RA: Read Address, RD: Read Data, SAx: Sector Address, PA: Program Address, PD: Program Data
CA0 0x*****AA8
User mode
CA1 0x*****554
Bit No. 7 6 5 4 3 2 1 0
Flag name CERS PGMS ESPS ERSEC SERS READ HANG RDY
Reset 0 0 0 0 0 0 0 0
Command 0 0 0 0 0 1 0 1
Program 0 1 0 0 0 0 0 0
Macro erase 1 0 0 0 0 0 0 0
Sector erase 0 0 0 0 1 0 0 0
Sector read
0 0 1 1 1 1 0 1
Interruption of during erasure
sector Not-target
erasure sector read 0 0 1 0 1 1 0 1
during erasure
Program 0 1 0 0 0 0 1 0
Hang-up 1 Macro erase 1 0 0 0 0 0 1 0
Sector erase 0 0 0 0 1 0 1 0
PGMS (Program Status) bit: This bit indicates the programming status.
CERS (Chip Erase Status) bit: This bit indicates the macro erase status. Any command can be received until
macro erase is completed.
SERS (Sector Erase Status) bit: This bit indicates the sector erase status. During sector erase, sector erase
suspend commands can be received.
ESPS (Erase Suspend Status) bit: This bit indicates the sector erase suspend status. Reading and
programming can be done for sectors other than erase targets. They cannot be done for sectors that are erase
targets. The sector erase resume command resumes sector erase.
ERSEC (Erase Suspend Sector status) bit: This bit indicates the status in which a target sector read is being
executed while sector erase is suspended. At this time, the data read from flash memory is not the correct data.
READ (Read) bit: This bit indicates the readable status of the TCFLASH.
HANG (Hang-up 1 status) bit: This bit indicates the Hang-up 1 status, which indicates that one of the following
events occurred:
An attempt has occurred to overwrite with value “1” an address to which the value of “0” has been written.
Programming, macro erase, and sector erase are not completed within the time limit.
In the Hang-up 1 status, the status of the TCFLASH can be recovered by writing a command reset.
RDY (Ready) bit: This bit indicates the programmable/erasable status of the TCFLASH or WorkFlash memory.
When the WorkFlash memory is programmable/erasable, this bit becomes “0”.
The TCFLASH status can be confirmed with the READ and RDY bits.
4 Command
This section describes the following commands:
0xyyyy_yyyy
Reprogramming Reprogramming
RAM Region Program Program
(program/data)
Data, Stack Data, Stack
Return
Reprogramming Reprogramming
User Data User Data
Start
FCFG_WARBR: No
WERSTS == 1
Yes
End
Write enable can be set using the program enable release (FCFG_WARBR:WERINT) interrupt instead of the
monitoring program enable release status (FCFG_WARBR:WERSTS) bit.
To confirm the completion of the flash program/erase, check that the programming/erasing ready bit
(TCFCFG_FSTAT:RDY) has become “1”.
When programming/erasing is not required, to allow programming or erasing to the flash using the WorkFlash
interface or Secure Hardware Extension (SHE), set the program enable bit (TCFCFG_FCFGR:WE) to “0”.
Start
No
SERS bit == 1
Yes
No
HANG bit == 1
Yes
Start
Register No
TCFCFG_FSTAT.RDY
== 1
Yes
No
PGMS bit == 1
Yes
No
HANG bit == 1
Yes
Other data to Yes
program?
No
6 Related Documents
Technical Reference Manuals
o S6J3110 Series Hardware Manual (Doc.No.002-10667)
o S6J3120 Series Hardware Manual (Doc.No.002-04855)
o S6J3200 Series Hardware Manual (Doc.No.002-04852)
o S6J32E/F/G Series Hardware Manual (Doc.No.002-12500)
o Traveo Family Hardware Manual Platform Part for S6J3200 Series (Doc.No.002-04854)
o S6J3310/20/30/40/50 Series Hardware Manual (Doc.No.002-10185)
o Traveo Family HardwareManual Platform Part for S6J3310/3320/3330/3340/3350 Series (Doc.No.002-
07884)
o S6J3360/70 Series Hardware Manual (Contact Technical Support)
o Traveo Family HardwareManual Platform Part for S6J3360/3370 Series (Doc.No.002-07884)
o S6J3400 Series Hardware Manual (Doc.No.002-09919)
o Traveo Family Hardware Manual Platform Part for S6J3400 Series (Doc.No.002-07884)
Datasheets
o S6J311E/D/C/B Series Datasheet (Doc. No.002-05681)
o S6J311A/9/8 Series Datasheet (Doc. No.002-04632)
o S6J3120 Series Datasheet (Doc.No.002-04863)
o S6J3200 Series Datasheet (Doc.No.002-05682)
o S6J32E/F/G Series Datasheet (Doc.No.002-10689)
o S6J3310/20/30/40 Series Datasheet (Doc.No.002-10635)
o S6J3350 Series Datasheet (Doc.No.002-10634)
o S6J3360/70 Series Datasheet (Contact Technical Support)
o S6J3400 Series Datasheet (Doc.No.001-97829)
Document History
Document Title: AN212061 - Programming and Erasing Flash Memory by User Program for Traveo™ Family
Document Number: 002-12061
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
© Cypress Semiconductor Corporation, 2016-2017. This document is the property of Cypress Semiconductor Corporation and its subsidiaries,
including Spansion LLC (“Cypress”). This document, including any software or firmware included or referenced in this document (“Software”), is owned
by Cypress under the intellectual property laws and treaties of the United States and other countries worldwide. Cypress reserves all rights under such
laws and treaties and does not, except as specifically stated in this paragraph, grant any license under its patents, copyrights, trademarks, or other
intellectual property rights. If the Software is not accompanied by a license agreement and you do not otherwise have a written agreement with
Cypress governing the use of the Software, then Cypress hereby grants you a personal, non-exclusive, nontransferable license (without the right to
sublicense) (1) under its copyright rights in the Software (a) for Software provided in source code form, to modify and reproduce the Software solely for
use with Cypress hardware products, only internally within your organization, and (b) to distribute the Software in binary code form externally to end
users (either directly or indirectly through resellers and distributors), solely for use on Cypress hardware product units, and (2) under those claims of
Cypress’s patents that are infringed by the Software (as provided by Cypress, unmodified) to make, use, distribute, and import the Software solely for
use with Cypress hardware products. Any other use, reproduction, modification, translation, or compilation of the Software is prohibited.
TO THE EXTENT PERMITTED BY APPLICABLE LAW, CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD
TO THIS DOCUMENT OR ANY SOFTWARE OR ACCOMPANYING HARDWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. To the extent permitted by applicable law, Cypress reserves the right to
make changes to this document without further notice. Cypress does not assume any liability arising out of the application or use of any product or
circuit described in this document. Any information provided in this document, including any sample design information or programming code, is
provided only for reference purposes. It is the responsibility of the user of this document to properly design, program, and test the functionality and
safety of any application made of this information and any resulting product. Cypress products are not designed, intended, or authorized for use as
critical components in systems designed or intended for the operation of weapons, weapons systems, nuclear installations, life-support devices or
systems, other medical devices or systems (including resuscitation equipment and surgical implants), pollution control or hazardous substances
management, or other uses where the failure of the device or system could cause personal injury, death, or property damage (“Unintended Uses”). A
critical component is any component of a device or system whose failure to perform can be reasonably expected to cause the failure of the device or
system, or to affect its safety or effectiveness. Cypress is not liable, in whole or in part, and you shall and hereby do release Cypress from any claim,
damage, or other liability arising from or related to all Unintended Uses of Cypress products. You shall indemnify and hold Cypress harmless from and
against all claims, costs, damages, and other liabilities, including claims for personal injury or death, arising from or related to any Unintended Uses of
Cypress products.
Cypress, the Cypress logo, Spansion, the Spansion logo, and combinations thereof, WICED, PSoC, CapSense, EZ-USB, F-RAM, and Traveo are
trademarks or registered trademarks of Cypress in the United States and other countries. For a more complete list of Cypress trademarks, visit
cypress.com. Other names and brands may be claimed as property of their respective owners.