RTA Knowledge Base

Table of Contents
What is FLS (Flash)

Flash memory (FLS) is a type of non-volatile memory that retains data even when the power is turned off. It is widely used in embedded systems for storing firmware, application code, and other critical data that must persist across power cycles. This application note based on TC399 FLS configurations, some of the parameters you see here it might be different on some other microcontrollers configurations.  

Functions of FLS

The primary functions of the FLS include:

  • Read: Functions to read data from specified flash memory addresses.
  • Write: Functions to write data to specified flash memory addresses.
  • Erase: Functions to erase specified sections or blocks of flash memory.Get Status: Functions to check the status of ongoing flash operations.
  • Error Handling: Functions to handle errors that may occur during flash operations.
  • Flash Memory Protection: Mechanisms to protect certain areas of flash memory from being written to or erased inadvertently.

MCAL Configurations

FlsConfigSet

FlsAcErase 

This parameter defines the address offset in RAM where the erase flash access code shall be loaded.

  • Choose an address offset within the RAM that does not conflict with other RAM usage.
  • Ensure that this address is correctly aligned and mapped according to the MCU’s memory map.
  • For example, if the erase operation code needs to reside in a specific memory section, calculate the appropriate offset and set it here.

FlsAcWrite 

This parameter specifies the address offset in RAM where the write flash access code shall be loaded.

  • Similar to FlsAcErase, select an address offset in RAM that avoids conflicts and ensures correct alignment.
  • Verify that the address is mapped according to the hardware design and memory management strategy.
  • Proper placement is crucial for efficient write operations and system stability.

FlsCallCycle 

Defines the cycle time for calls to the flash driver's main function, measured in seconds.

  • Set the call cycle time based on the system's real-time requirements and the urgency of flash operations.
  • A shorter cycle time (e.g., 0.0001 seconds) increases the frequency of flash operations but can increase CPU load.
  • Balance the cycle time to optimize performance and system responsiveness without overloading the processor.

FlsDefaultMode

Determines the default mode of the FLS device after initialization (e.g., SLOW, FAST).

  • Set this parameter based on the typical operation mode required by your application.
  • For applications needing frequent and rapid access, a FAST mode might be preferable.
  • For regular operations where energy consumption or performance is less critical, SLOW mode might be sufficient.

FlsMaxReadFastMode

Specifies the maximum number of bytes to read or compare in one cycle of the flash driver's job processing function in fast mode.

  • Configure this value to be higher than FlsMaxReadNormalMode.
  • Determine the optimal byte count based on the application's performance requirements and memory access patterns.
  • Ensure it balances between rapid data retrieval and the system's ability to process the data efficiently.

FlsMaxReadNormalMode

Indicates the maximum number of bytes to read or compare in one cycle of the flash driver's job processing function in normal mode.

  • Set this value considering the typical data access patterns during normal operation.
  • Optimize for a balance between data throughput and system resource usage.
  • Ensure it’s lower than FlsMaxReadFastMode to provide differentiated performance modes.

FlsMaxWriteFastMode (32 -> 32)

Maximum number of bytes to write in one cycle of the flash driver's job processing function in fast mode.

  • Since the range is fixed (32 -> 32), no configuration changes are required. This implies a fixed block size for fast mode write operations.

FlsMaxWriteNormalMode (32 -> 32)

Maximum number of bytes to write in one cycle of the flash driver's job processing function in normal mode.

  • Similar to FlsMaxWriteFastMode, this parameter has a fixed value. Ensure that the application aligns with this block size for write operations.

FlsProtection 

Defines erase/write protection settings, relevant if supported by hardware.

  • Configure this parameter based on the security and protection requirements of your application.
  • Set appropriate protection bits to prevent unauthorized or accidental erasure/writing of critical flash memory sections.
  • Refer to the hardware documentation to correctly map protection settings.

FlsWaitStateRead

Specifies the wait state configuration for read access from DFLASH.

  • Set the wait state based on the access time requirements and the speed of the flash memory.
  • Optimize the wait state to balance read access speed with system stability and performance.

FlsWaitStateErrorCorrection

Specifies the wait state configuration for error correction during read access.

  • Configure this parameter to ensure sufficient time for error correction processing without compromising read performance.
  • Optimize the wait state to enhance data integrity and reliability while maintaining acceptable read speeds.

FlsGeneral

FlsAcLoadOnJobStart

Specifies whether the flash driver should load the flash access code to RAM whenever an erase or write job is started and unload it after the job is finished or canceled.

  • Enable this feature if your application requires dynamic loading of flash access code to optimize RAM usage and ensure efficient job execution.
  • Disable if the access code is static and always resides in RAM.

FlsBaseAddress

Defines the start address of the flash memory.

  • Set this to the base address of the flash memory as specified in the hardware documentation.
  • Ensure alignment with the MCU's memory map.

FlsBlankCheckApi

Compile switch to enable or disable the Fls_BlankCheck function.

  • Enable this API if you need to check whether sections of the flash memory are blank (unprogrammed).
  • Disable to reduce code size if this function is not required.

FlsInitCheckApi

Adds or removes the Fls_17_Dmu_InitCheck() service from the code.

  • Enable if your application requires verification of initialization status.
  • Disable to save memory and processing resources if initialization verification is not needed.

FlsEccErrorInfoApi

Enables or disables the service to get the page address of the most recent ECC error.

  • Enable this API if error correction and tracking are critical for your application.
  • Disable if ECC error tracking is not required to save on code space and execution time.

FlsCancelApi

Compile switch to enable or disable the Fls_Cancel function.

  • Enable if you need the capability to cancel ongoing flash operations.
  • Disable to reduce code complexity and size if cancellation is not necessary.

FlsCompareApi

Compile switch to enable or disable the Fls_Compare function.

  • Enable if your application needs to compare data in flash memory.
  • Disable if this functionality is not required to save resources.

FlsDevErrorDetect

Switches the Default Error Tracer (Det) detection and notification on or off.

  • Enable for development and debugging purposes to catch and diagnose errors.
  • Disable in the final production code to reduce overhead if error detection is not needed.

FlsRunTimeErrorDetect

Switches the Runtime Error Tracer detection and notification on or off.

  • Enable for runtime error detection during the development phase.
  • Disable in the production environment if runtime error detection is not required.

FlsSafetyEnable

Switch to enable or disable the Safety Error.

  • Enable if safety-critical error detection is necessary for your application.
  • Disable if safety-related error detection is not required to save resources.

FlsIfxFeeUse

Enables or disables the use of IFX FEE functions.

  • Enable if your application uses Infineon's Flash EEPROM Emulation (FEE).
  • Disable if FEE is not needed.

FlsDriverIndex (0 -> 254)

Index of the driver, used by FEE.

  • Assign a unique index to the driver if mulle drivers are used.
  • Ensure the index does not conflict with other drivers.

FlsEraseVerificationEnabled

Compile switch to enable erase verification.

  • Enable to ensure that erase operations are verified for correctness.
  • Disable if verification is not required to save execution time.

FlsGetJobResultApi

Compile switch to enable or disable the Fls_GetJobResult function.

  • Enable to check the result of flash operations.
  • Disable if this functionality is not needed.

FlsGetStatusApi

Compile switch to enable or disable the Fls_GetStatus function.

  • Enable if you need to query the status of the flash driver.
  • Disable to reduce code size if status checking is not necessary.

FlsSetModeApi

Compile switch to enable or disable the Fls_SetMode function.

  • Enable to allow changing the operating mode of the flash driver.
  • Disable if mode switching is not required.

FlsTimeoutSupervisionEnabled

Compile switch to enable timeout supervision.

  • Enable to supervise the timeout of flash operations.
  • Disable if timeout supervision is not required.

FlsTotalSize

The total amount of flash memory in bytes.

  • Set this to the total size of the flash memory as specified in the hardware documentation.
  • Ensure it matches the actual memory size to avoid addressing errors.

FlsUseInterrupts

Job processing triggered by hardware interrupt.

  • Enable if you want flash operations to be handled via interrupts for better performance.
  • Disable if polling or other methods are preferred.

FlsVersionInfoApi

Pre-processor switch to enable or disable the API to read out the module's version information.

  • Enable if version tracking is required for diagnostics and maintenance.
  • Disable if version information is not needed.

FlsWriteVerificationEnabled

Compile switch to enable write verification.

  • Enable to verify the integrity of write operations.
  • Disable if write verification is not required.

FlsInitApiMode

This parameter selects the operating modes for Flash initialization.

  • Choose an initialization mode that aligns with your application’s startup requirements.
  • Common modes might include normal initialization or safety-critical initialization.

FlsRuntimeApiMode

This parameter selects the operating modes for Flash runtime operations.

  • Select a runtime mode based on the operational requirements, balancing performance and safety needs.
  • Modes could vary from normal operation to high-speed or safe operation modes.

FlsPublishedInformation

FlsAcLocationErase

Position in RAM where the erase flash access code should be loaded.

  • Set this to a RAM address that is reserved for loading the erase access code.
  • Ensure the address does not overlap with other critical data or code areas to avoid conflicts.

FlsAcLocationWrite

Position in RAM where the write flash access code should be loaded.

  • Set this to a RAM address that is reserved for loading the write access code.
  • Ensure the address is properly aligned and does not interfere with other RAM usage.

FlsAcSizeErase

Number of bytes in RAM needed for the erase flash access code.

  • Determine the size based on the erase code provided by the flash driver.
  • Ensure sufficient RAM is allocated to accommodate the entire erase code.

FlsAcSizeWrite

Number of bytes in RAM needed for the write flash access code.

  • Determine the size based on the write code provided by the flash driver.
  • Ensure sufficient RAM is allocated to accommodate the entire write code.

FlsEraseTime

Maximum time required to erase one complete flash sector.

  • Set this value based on the flash memory specifications provided by the manufacturer.
  • Ensure the time is adequate to complete the erase operation for the largest sector.

FlsErasedValue

The value of an erased flash memory cell.

  • Set this to the value that represents an erased state, usually 0xFF for most flash memories.
  • Confirm the erased value from the flash memory's datasheet.

FlsExpectedHwId

Unique identifier of the hardware device that is expected by this driver.

  • Set this to the hardware ID provided by the MCU or flash memory manufacturer.
  • Ensure it matches the ID for which the driver is implemented to avoid compatibility issues.

FlsSpecifiedEraseCycles

Number of erase cycles specified for the flash device, usually given in the device datasheet.

  • Set this to the maximum erase cycles as specified by the flash memory manufacturer.
  • Use this parameter to plan for the flash memory's lifecycle and maintenance schedules.

FlsWriteTime

Maximum time required to program one complete flash page.

  • Set this value based on the programming time specified in the flash memory datasheet.
  • Ensure the time covers the worst-case scenario to guarantee reliable programming operations.

FlsIfxSpecificConfig

FlsStateVarStruct

This parameter provides the name of the structure containing all the global variables specific to the Flash driver.

  • Define a structure in your code that holds all the global variables used by the Flash driver.
  • Assign the name of this structure to the FlsStateVarStruct parameter.
  • Ensure that the structure is properly initialized and maintained throughout the Flash driver's lifecycle.

FlsUseEraseSuspend

Compile switch to enable or disable the FLS erase suspend and erase resume feature.

  • Enable this feature if your application needs to temporarily suspend flash erase operations to perform other critical tasks.
  • Disable to simplify the flash driver's operation and reduce code size if erase suspension is not required.

FlsEraseSuspendTimeout (12000 -> 65535)

Timeout for the Erase Suspend feature, specified as a loop count.

  • Set this value based on the maximum expected time to safely suspend an erase operation.
  • Ensure the timeout is adequate to handle worst-case scenarios, but not excessively long to avoid unnecessary delays.

FlsIllegalStateNotification

Pointer to a notification function that is called when the Flash driver reaches an illegal state. In such a state, the Flash driver cannot proceed, and no more Flash requests should be triggered; a system reset is recommended.

  • Implement a function that handles illegal states, possibly logging the error, performing cleanup, and initiating a system reset.
  • Assign the pointer to this function to the FlsIllegalStateNotification parameter.
  • Ensure the function is robust and capable of handling critical errors effectively to maintain system integrity.

Other 

FlsJobEndNotification

This parameter is mapped to the job end notification routine provided by some upper layer module, typically the Fee (Flash EEPROM Emulation) module.

  • Implement a function in the upper layer (e.g., Fee module) that will handle the successful completion of flash operations.
  • Assign the pointer to this function to the FlsJobEndNotification parameter.
  • Ensure the function is capable of handling job completions appropriately, such as updating status, logging, or triggering subsequent operations.

FlsJobErrorNotification

This parameter is mapped to the job error notification routine provided by some upper layer module, typically the Fee module.

  • Implement a function in the upper layer that will handle errors during flash operations.
  • Assign the pointer to this function to the FlsJobErrorNotification parameter.
  • Ensure the function handles errors robustly, such as logging errors, retrying operations, or entering a safe state.

FlsEraseVerifyErrNotif

Description: This parameter is mapped to the erase verification error (EVER) notification routine provided by some upper layer module, typically the Fee module.

  • Implement a function in the upper layer that will handle errors detected during erase verification.
  • Assign the pointer to this function to the FlsEraseVerifyErrNotif parameter.
  • Ensure the function can address verification errors, such as re-erasing the sector or flagging it for maintenance.

FlsProgVerifyErrNotif

Description: This parameter is mapped to the program verification error (PVER) notification routine provided by some upper layer module, typically the Fee module.

  • Implement a function in the upper layer that will handle errors detected during program verification.
  • Assign the pointer to this function to the FlsProgVerifyErrNotif parameter.
  • Ensure the function addresses verification errors effectively, such as retrying the write operation or marking the flash block as unreliable.


Note:  When configuring these parameters, ensure they align with your application's requirements and capabilities of your hardware, and the specifications of your CAN communication protocol. Refer to documentation and guidelines provided by supplier regarding each parameter.


  • No labels