AN694 SILABS [Silicon Laboratories], AN694 Datasheet

no-image

AN694

Manufacturer Part Number
AN694
Description
WRITING TO FLASH FROM FIRMWARE ON SiM3XXXX DEVICES
Manufacturer
SILABS [Silicon Laboratories]
Datasheet
W
1. Introduction
This application note applies to the SiM3Cxxx, SiM3Uxxx, and SiM3Lxxx device families. The Flash memory on all
Silicon Labs MCU devices is readable and writable from application code. This capability allows user software to
store values, such as calibration constants or system parameters, to the Flash and to implement a boot-loading
feature in which user firmware can be updated in-system from a remote site. The Flash that is not used by
application code can be treated like an EEPROM, thus negating the need to connect an external EEPROM to the
device.
This document starts with the basics of accessing Flash from application code on any device, including device-
specific details. Then, it discusses advanced routines that can be developed from the basic routines. Finally, it
describes precautions to take when writing or erasing Flash. Example code for the basic routines for all devices is
installed with the Precision32 SDK, which can be downloaded from www.silabs.com/32bit-software.
2. Key Points
Rev. 0.1 9/12
RITING T O







Firmware should disable interrupts when writing or erasing Flash to ensure the Flash interface accesses are
The voltage supply monitor must be enabled in the VMONn module during Flash write and erase
operations.
The voltage supply monitor must be enabled as a reset source in the RSTSRCn module during Flash write
and erase operations.
Note:Any write or erase operations initiated while the voltage supply monitor is disabled or the voltage supply monitor is
A Lock and Key sequence must be executed before executing a write or erase operation. The Flash
interface can be unlocked for one or multiple write or erase operations.
Writes to the WRDATA register while the Flash interface is locked or an incorrect unlock sequence will
permanently lock the Flash interface until the next device reset.
sequential in time and take the minimum time possible.
For all Flash write operations, firmware will stall unless operating from a memory space other than Flash.
Interrupts posted during a Flash write or erase operation will be held pending until the completion of the
Flash operation, after which they will be serviced in priority order.
disabled as a reset source will be ignored.
F
L A S H FROM
Copyright © 2012 by Silicon Laboratories
F
IRMWARE ON
S i M 3
X X X X
AN694
D
EVI C E S
AN694

Related parts for AN694

AN694 Summary of contents

Page 1

... For all Flash write operations, firmware will stall unless operating from a memory space other than Flash.  Interrupts posted during a Flash write or erase operation will be held pending until the completion of the Flash operation, after which they will be serviced in priority order. Rev. 0.1 9/12 F IRMWARE ON Copyright © 2012 by Silicon Laboratories AN694 EVI AN694 ...

Page 2

... AN694 3. Flash Essentials Different device series have many similarities for Flash, including page sizes, lock bits, and the instructions used to read and write to Flash. The main differences are the amount of Flash available, how the voltage supply monitor is enabled, how the voltage supply monitor is enabled as a reset source, and how registers are modified to allow Flash writes and erases ...

Page 3

... Firmware writes 0x0000_0000 to the lock word. The location for the Flash lock word will differ between devices, so consult the device reference manual for more information. Reserved Lock Word 0x0003_FFFC Reserved Flash Reserved Lock Word 0x0003_FFFC Reserved Flash Rev. 0.1 AN694 3 ...

Page 4

... AN694 3.3. Device-Specific Notes Various MCUs have features that require consideration when accessing Flash. 3.3.1. SiM3Cxxx, SiM3Uxxx, and SiM3Lxxx Flash Lock and Key All SiM3Cxxx, SiM3Uxxx, and SiM3Lxxx devices' writes and erases to Flash are protected with a lock and key function. The Flash Lock and Key Register (FLASHCTRLn) must be written with the correct key codes in sequence before Flash operations may be performed ...

Page 5

... Repeat steps 8 and 9 until all data is written. Hardware automatically increments the WRADDR field by 2 after each write operation. 11. (Optional) If executing code from a memory space other than Flash, poll on the BUSYF flag until hardware clears 12. Write the multiple lock value to KEY (0x5A). 13. Enable interrupts. Rev. 0.1 AN694 5 ...

Page 6

... AN694 4.4. Writing Multiple Half-Words to Non-Sequential Flash Addresses All bits, fields, and registers referred to in this sequence are in the FLASHCTRLn module. To write multiple bytes to non-sequential addresses in Flash: 1. Ensure the voltage supply monitor is enabled and enabled as a reset source (device reset sources and VMONn modules) ...

Page 7

... HAL and non-HAL methods on various device families. 5.1.1. SiM3Cxxx/SiM3U1xx/SiM3L1xx Devices Enable voltage supply monitor: SI32_VMON_0->CONTROL.VMONEN = 1; // non-HAL SI32_VMON_A_enable_vdd_supply_monitor(SI32_VMON_0); // HAL Enable voltage supply monitor as a reset source: SI32_RSTSRC_0->RESETEN.VMONREN = 1; // non-HAL SI32_RSTSRC_A_enable_vdd_monitor_reset_source(SI32_RSTSRC_0); // HAL Enable the high voltage monitor threshold: Rev. 0.1 AN694 7 ...

Page 8

... AN694 SI32_VMON_0->CONTROL.VDDHITHEN = 1; // non-HAL SI32_VMON_A_select_vdd_high_threshold(SI32_VMON_0); // HAL 5.2. AHB Clock 1. If operating from an external crystal, be advised that crystal performance is susceptible to electrical interference and is sensitive to layout and changes in temperature. If the system is operating in an electrically noisy environment, use one of the internal oscillators or an external CMOS clock. ...

Page 9

... N : OTES Rev. 0.1 AN694 9 ...

Page 10

... AN694 C I ONTACT NFORMATION Silicon Laboratories Inc. 400 West Cesar Chavez Austin, TX 78701 Tel: 1+(512) 416-8500 Fax: 1+(512) 416-9669 Toll Free: 1+(877) 444-3032 Please visit the Silicon Labs Technical Support web page: https://www.silabs.com/support/pages/contacttechnicalsupport.aspx and register to submit a technical support request. The information in this document is believed to be accurate in all respects at the time of publication but is subject to change without notice. ...

Related keywords