Using eeprom memory to design peripheral driver circuits

The biggest challenge developers face is the lack of clear separation between core and non-core domains. As a result, much of their time is spent writing code that isn't reusable or directly relevant to the product's competitive edge. This often leads to neglecting critical areas such as requirements analysis, algorithms, user experience, and software engineering best practices. Consequently, the amount of maintenance required for the codebase far exceeds the initial development investment. Teams that create successful products not only have stable and skilled workforces but also operate with a different mindset. They adopt effective development strategies and master technologies quickly, outperforming so-called "old programmers." While many companies offer high salaries, not all teams produce marketable products. The failure to deliver value can lead to wasted resources and missed opportunities for innovation. More than a decade ago, the author encountered similar challenges and decided to focus on developing standardized platform technology. This led to the creation of AWorks, which later gave rise to Ametal. Ametal enables cross-platform compatibility and defines standard interfaces for peripheral devices, making it possible to provide on-demand services. It has become a reality in modern embedded systems. ZLG supports this approach by offering a wide range of standard peripheral drivers and protocol components, aiming to build a complete ecosystem. Whether you choose any MCU, as long as it supports Ametal, you can achieve "one-time programming, lifelong use," eliminating the need to reinvent the wheel. **6.1 E2PROM Memory** E2PROM (Electrically Erasable Programmable Read-Only Memory) is a type of non-volatile memory that retains data even after power loss. This section uses FM24C02 as an example to explain how to use similar E2PROMs in Ametal. > > > **6.1.1 Device Introduction** The FM24C02 has a total capacity of 2K bits (256 bytes). Each byte corresponds to a unique address, ranging from 0x00 to 0xFF. Its page size is 8 bytes, meaning that writes cannot cross page boundaries. For instance, writing at address 0x08 must be completed before moving to 0x10. The internal structure is illustrated in Table 6.1. Table 6.1: FM24C02 Memory Organization Structure [Image: http://i.bosscdn.com/blog/11/25/21/1E1-0.jpg] The FM24C02 communicates via a standard I²C interface, using SDA and SCL lines. In an 8-pin SOIC package, the WP pin is used for write protection. If tied high, it prevents all writes, but typically, it is grounded for normal operation. [Image: http://i.bosscdn.com/blog/11/25/21/6126-1.jpg] Figure 6.1: FM24C02 Pin Definition The A2, A1, and A0 pins determine the I²C slave address, which is 0x50 when all are grounded. In Ametal, the device address is represented as a 7-bit address. The MicroPort-EEPROM module connects to the AM824-Core through the MicroPort interface. [Image: http://i.bosscdn.com/blog/11/25/21/Fc-2.jpg] Figure 6.2: EEPROM Circuit Schematic > > > **6.1.2 Initialization** Ametal provides driver functions for various I²C-based E2PROMs, including FM24C02, FM24C04, and FM24C08. Here’s an example for FM24C02: [Image: http://i.bosscdn.com/blog/11/25/21/E13-3.jpg] This function returns an instance handle, `fm24c02_handle`, which is used for subsequent operations. An instance of `am_ep24cxx_dev_t` represents a single FM24C02. Multiple instances can be defined if more than one device is connected to the I²C bus. The instance information includes the device’s slave address and model. [Image: http://i.bosscdn.com/blog/11/25/21/D07-4.jpg] For example, two FM24C02 devices would require three instances, each initialized separately. > > > **6.1.3 Reading and Writing Functions** Ametal provides functions for reading and writing E2PROM data. The prototypes are shown in Table 6.2. Table 6.2: EP24Cxx Read and Write Functions (am_ep24cxx.h) [Image: http://i.bosscdn.com/blog/11/25/21/2034-13.jpg] Writing data starts from a specified address: [Image: http://i.bosscdn.com/blog/11/25/21/2c5-14.jpg] Reading follows a similar pattern: [Image: http://i.bosscdn.com/blog/11/25/21/1201-16.jpg] Examples of writing and reading 16 bytes from address 0x20 are provided in Listings 6.3 and 6.4. > > > **6.1.4 NVRAM Universal Interface Functions** To simplify interactions with E2PROMs like FM24C02, Ametal offers a universal NVRAM interface. Before using these functions, set `AM_CFG_NVRAM_ENABLE` to 1 in your project configuration. The NVRAM initialization function sets up the interface for reading and writing. It requires an instance handle and a device name, allowing other modules to identify the specific E2PROM. [Image: http://i.bosscdn.com/blog/11/25/21/4c9-20.jpg] NVRAM organizes memory into segments, each with a name and unit number. These segments define logical storage areas, such as IP addresses or temperature limits. [Image: http://i.bosscdn.com/blog/11/25/21/3112-25.jpg] Once initialized, applications can read and write to these segments using the NVRAM interface, improving code readability and maintainability. In conclusion, using Ametal’s NVRAM interface allows developers to interact with E2PROMs in a clean, modular way, reducing complexity and improving portability across platforms.

Swing Radiator

Swing Radiator,Power Transformer Swing Radiator,Swing Type Radiator,Distribution Transformer Swing Radiator

Shenyang Tiantong Electricity Co., Ltd. , https://www.ttradiator.com

Posted on