SF_FLASH_WRITEPermalink

This is the web edition of the original ‎⮫ AC500-S safety user manual, version 1.3.2. This web edition is provided for quick reference only. The original safety user manual must be used to meet functional safety application requirements.

04.06.071_SF_FLASH_WRITE

Writing of user data to the flash memory

The function block writes a data set to a data segment in the flash memory. For that purpose, two data segments are available in the safety CPU. The delete operation (function block SF_FLASH_DEL) always deletes a data segment as a whole. One data segment consists of 1724 blocks (0 ... 1723). Each block comprises 38 bytes. The maximum number of writing cycles to the flash memory is limited. Deleting data in the flash memory is also considered to be a "writing" cycle.

After a delete operation, data can be written only once to each of these 1724 data segment blocks. If a block containing data is to be overwritten with new data, the entire data segment has to be deleted first. In doing so, all data in this segment will be lost.

NB blocks are read starting at address SM and stored in segment SEG starting at block BNR.

32 binary data or 16 word data or 8 double word data are read per block.

One block contains 38 bytes:

  • 32 bytes of data

  • 4 bytes for CRC checksum

  • 1 byte as "written" identifier

  • 1 byte for alignment

⮫ Table 1147 “Structure of one of the flash memory segments with user data”

Once the write operation for a data set has been started (by a FALSE/TRUE edge at input EN), the data contained in the data set must not be changed anymore until the write operation completes (DONE = TRUE). Storing the data set in the flash memory can take several safety CPU cycles.

With a FALSE/TRUE edge at input EN, the data set is written once. Input EN is not evaluated again until the storage procedure is finished (DONE = TRUE).

After the write operation is finished, the function block outputs DONE, ERR and ERNO are updated. Data storage was successful if DONE = TRUE and ERR = FALSE. If DONE = TRUE and ERR = TRUE, an error occurred. The error type is indicated at output ERNO.

A new FALSE/TRUE edge at input EN starts a new write operation. Input BNR must point to the next free block for the next write operation since no new data can be written to blocks that already contain data without a preceding deletion of the data segment.

NOTICE

NOTICE
NOTICE
NOTICE

NOTICE

NOTICE

This function block is activated by a positive edge of the input variable EN. During the cycle where the function block notices that the operation is finished (output DONE = TRUE) it will set the output variables only for one cycle. When the function block is called again it will reset the output variables immediately.

Table 1148: FB name: SF_FLASH_WRITE

Name

Data type

Initial value

Description, parameter values

VAR_INPUT

EN

BOOL

FALSE

Activation of the FB using a positive edge

The following applies:

  • EN = FALSE/TRUE edge: Reading the data set is carried out once.

  • EN = TRUE: The function block is not processed, i.e. it does not change its outputs anymore.

NB

WORD

16#0000

Number of data set blocks (decimal 1 .. 1724)

Input NB is used to specify the number of blocks contained in the data set. 32 byte data or 16 word data or 8 double word data are read per block.

Valid values: 1 ... 1724

Example:

- SM = ADR(%MW0.0) and NB = 1: Data are stored at %MW0.0 to %MW0.15 (1 block = 16 word data)

- SM = ADR(%MW0.0) and NB = 2: Data are stored at %MW0.0 to %MW0.31 (2 blocks = 32 word data)

SEG

BYTE

16#00

ID number of the data segment (16#01 or 16#02)

BNR

WORD

16#0000

Starting block number in the flash memory data segment (decimal 0 ... 1723)

SM

DWORD

16#00000000

Source start address (address of the first variable from where the data will be written to the flash memory)

At input SM, the address of the first variable of the data set is specified using an ADR operator. Once the write operation for a data set has been started (by a FALSE/TRUE edge at input EN), the data contained in the data set must not be changed anymore until the write operation is finished (DONE = TRUE).

VAR_OUTPUT

DONE

BOOL

FALSE

Writing procedure is completed (DONE = TRUE)

This output always has to be considered together with output ERR.

The following applies:

  • DONE = TRUE and ERR = FALSE: Write operation completed. The data set has been stored in the flash.

  • DONE = TRUE and ERR = TRUE: An error occurred during the write operation. Output ERNO indicates the error number.

ERR

BOOL

FALSE

Error occurred (data segment could not be written)

Output ERR indicates whether an error occurred during the write operation. This output always has to be considered together with output DONE. The following applies if an error occurred: DONE = TRUE and ERR = TRUE. Output ERNO indicates the error number.

ERNO

WORD

16#0000

Error number⮫ [3]

Output ERNO indicates an error number. This output always has to be considered together with the outputs DONE and ERR.

The SF_FLASH_WRITE operation may take quite a long time since the safety PLC user program is processed with higher priority. Output ERNO then indicates that the function block has started the execution (0x0FFF = BUSY).

During this phase, the outputs ERR and DONE are set to FALSE.

Call in ST

WRITE_FLASH(EN := EN_FLASH_WRITE,
NB := NB_FLASH_WRITE,
SEG := SEG_FLASH_WRITE,
BNR := BNR_FLASH_WRITE,
SM := SM_FLASH_WRITE,
DONE => DONE_FLASH_WRITE,
ERR => ERR_FLASH_WRITE,
ERNO => ERNO_FLASH_WRITE);