
Application Note EEPROM Handling in Remote Control Devices Using the Crimzon® MCU AN026201-0707 Abstract choice when selecting the right device for your appli- cation. At Zilog, we are continually evolving our In many remote control applications, an EEPROM is Crimzon microcontroller roadmap so that you can used to permanently store important data. Care must expect new, smaller packages and added-feature sili- be taken, however, to prevent data corruption caused con that will further enhance your product offerings. by incomplete WRITE cycles, power interruptions, and external noise. Discussion This application note focuses on proper use of the An EEPROM is commonly used in remote control ® Crimzon MCU in remote control devices to ensure applications to save data when the power is off. data integrity in EEPROMs. Focus is on the opera- There are numerous EEPROM suppliers in the mar- tional flow of the Crimzon MCU. ket. Most use the standard I2C communication for the communication interface. (Refer to the EEPROM Note: The source code associated with this specification for details on using the I2C interface.) reference design is available under Crimzon Applications Code Library Table 1 provides a sample of the Atmel serial in Application Sample Libraries on EEPROM product list. www.zilog.com. In remote control devices, EEPROMs are used for Crimzon Microcontrollers two primary purposes: With one of the broadest device databases available • One is to store the basic code numbers for user- today, Zilog's Crimzon line of microcontrollers offers programmed data and for factory-loaded data. the design flexibility required to create a wide variety A 1K EEPROM is usually adequate for this of infrared products. Our living database of infrared purpose. remote control codes, ZBASE®, allows you to sup- port the latest infrared applications on the market, • The other is to store the learning signal data in including universal remote controls, wireless key- a learning remote control. For such purposes, boards, wireless mice, and game controllers. Zilog’s EEPROMs from 4 K to 32 K are used depend- advanced data compression algorithms squeeze more ing on the number of keys to be learned. device data into the available ROM. You get more Different EEPROMs can have different page sizes device support for your money because Crimzon (from 4 bytes to 256 bytes) and address pins (A0 - microcontrollers are simpler to integrate. A2). Designers must take care to study the device’s interface method and select the appropriate page Zilog’s broad range of cost-effective, low-power read/write method. Crimzon microcontrollers provides the ability to meet the requirements of a range of device footprints: 20-pin, 28-pin, 40-pin and 48-pin in DIP, SOIC and SSOP. Memory is available in sizes from 4 K to 64 K ROM and up to 128 K OTP, giving you greater AN026201-0707 Page 1 of 8 EEPROM Handling in Remote Control Devices Using the Crimzon® MCU Table 1. Atmel's 2-Wire Serial EEPROM Family Size Page Size Maximum Addresses Device (Bytes) (Bytes) Per Bus Used AT24C11 1 K 4 1 None AT24C01A 1 K 8 8 A0, A1, A2 AT24C02 1 K 8 8 A0, A1, A2 AT24C04 4 K 16 4 A1, A2 AT24C08A 8 K 16 2 A2 AT24C16A 16 K 16 1 None AT24C164 16 K 16 8 A0, A1, A2 AT24C32A 32 K 32 8 A0, A1, A2 AT24C64A 64 K 32 8 A0, A1, A2 AT24C128 128 K 64 4 A0, A1 AT24C128B 128 K 64 8 A0, A1, A2 AT24C256 256 K 64 4 A0, A1 AT24C256B 256 K 64 8 A0, A1, A2 AT24C512 512 K 128 4 A0, A1 AT24C512B 512 K 128 8 A0, A1, A2 AT24C1024 1 M 256 2 A1 Hardware Architecture • SCL: Serial Clock Input The Crimzon MCU 8-pin small package is shown in • SDA: Serial Data Figure 1. The SCL is driven either directly by an MCU output pin with push-pull, or by an open-drain output using a 2 KΩ pull-up resistor. Ports P34 or P37 are push- pull outputs that can be used for that purpose. Any pin of ports P20-P27 can also be used as push-pull output or open-drain with 2 KΩ pull-up resistor. The SDA must be driven by an open-drain output with 2 KΩ pull-up resistor. The EEPROM sends an Figure 1. Crimzon MCU, 8-Pin Small Package ACK signal by pulling the SDA pin down at the 9th bit period. The SDA pin must therefore be a bidirec- The pins provide access to the following functions: tional pin that supports the open-drain output config- uration. Any pin of Crimzon MCU ports P20-P27 can be used to drive the SDA pin. Configure the port as • A0 - A2: Address Inputs open-drain with a 2 KΩ pull-up resistor during data • WP: Write Protect pulses. After sending 8 clocks, the MCU pin must be AN026201-0707 Page 2 of 8 EEPROM Handling in Remote Control Devices Using the Crimzon® MCU configured as input pin to read the ACK at the 9th clock. See Figure 2. Figure 2. Output Acknowledge Timing Diagram Software Implementation for Read/ interfacing the Crimzon MCU to an EEPROM via Write Operations I2C. An EEPROM supports random access, sequential Figure 3 illustrates the byte write operation. Figure 4 access, and page access. (Refer to your EEPROM illustrates the page write operation. A flowchart for specification for further information.) Zilog applica- EEPROM handling is provided in Appendix A – tion note AN0036 also provides example code for Flowcharts. Figure 3. Byte Write Operation Figure 4. Page Write Operation AN026201-0707 Page 3 of 8 EEPROM Handling in Remote Control Devices Using the Crimzon® MCU Prevention of Data Corruption 1. Eliminate single-key-triggered WRITE pro- cesses. An EEPROM is designed for permanent data storage. The data is preserved even though the power is In some applications, a manufacturer may want removed during battery replacement in remote con- the remote to remember the device mode (TV, trol. However, there is still a risk of corrupting the VCR, DVD, Satellite, Cable, Audio, etc.). The EEPROM data during a write operation. device mode is usually modified when a device key is pressed. In that case, store the device Causes of data corruption in EEPROMs include: mode status in RAM only. Avoid an EEPROM WRITE after a single key press and you will 1. Incomplete Write Cycle avoid data corruption if the device suddenly loses Vcc power. The I2C interface is a static bus, and the MCU can control the speed of that bus while per- For example, the user can easily press a device forming other activities. However, if the MCU key by accident while removing the battery. is interrupted and loses track of the EEPROM With a single-key-triggered WRITE procedure, writing procedure, the EEPROM data may get the accidental key press triggers a WRITE of corrupted. device mode data into EEPROM. Since the battery is being removed, however, the Vcc 2. Power Interrupt power naturally drops below the RESET volt- An EEPROM needs between 5 ms and 10 ms age for the Crimzon MCU. The MCU then to write data into its permanent storage area. If stops operation. As Vcc drops below the the power is interrupted prior to the WRITE EEPROM operating voltage, data integrity is completion, the new data will be lost. Existing jeopardized. Data will likely be corrupted. data may also be corrupted. It is important to ensure that the power is stable during the Trigger an EEPROM WRITE process by a EEPROM WRITE cycle. multiple key press sequence and such acciden- tal data loss can be almost completely avoided. 3. External Noises/Pulses 2. Low Voltage Detection Other events may inject extra pulses into the I2C bus. For example, if the I2C bus is multi- The Low Voltage Detection flag (bit 1 of LVD plexed with a key scanning matrix, pulses can register 0x0C in bank 0x0D) will be set when be injected into the bus when a user presses a the voltage is lower than the VLVD (typically key on the keypad. 2.4 V) when low voltage detection is enabled. Write only to the EEPROM when voltage is Prevention of EEPROM Corruption During high. WRITE Operations Quality Check on EEPROM data There are simple rules to follow that will help you avoid EEPROM data corruption. The chance of EEPROM data corruption can be min- imized by a WRITE at the right time. The EEPROM should be written only when the pro- gram modifies the data. For example, if the When the EEPROM is read, you must still verify that EEPROM contains the user-programmed code num- the data is totally reliable. Different EEPROM sizes ber of each device, perform a WRITE to the have different page sizes for WRITE and READ EEPROM only when the programmed code number operations. If the PAGE WRITE process stops before is modified, or upon power-up initialization. it has completed, the whole page of data will be cor- AN026201-0707 Page 4 of 8 EEPROM Handling in Remote Control Devices Using the Crimzon® MCU rupted. If the power is lost before the required 5 ms to 0x5A). If the RAM data is valid, there is no need to 10 ms WRITE cycle, some data (pages or bytes) will read the EEPROM. Proceed with normal operation. be lost. Such situations occur during, Stop Mode Recovery, Watchdog timeout reset, and when the RESET pin 1. Checksum and Signature Byte goes LOW. A checksum byte and a signature byte can be If the RAM data is not valid, the MCU should read inserted into a page of data (e.g.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages8 Page
-
File Size-