Now Live: Digital Assistant for Hardware Development
Hardware configuration for different PCB revisions or hardware variants needs to be hard-coded when firmware development is still at the early stage. There are two classic ways to achieve this, and an advanced method is also available. This article explores three common techniques for configuring Hardware Identification (HWID).
Conceptual Basics
High, Low, and High-Z States: For each ID position, there are three states: high, low, and high-Z (high impedance or 'floating').
Weak Internal vs. Strong External Resistors: Internal pull-up and pull-down resistors are generally weaker compared to external resistors. When an external resistor is connected, it will "override" the effect of the internal resistor due to its stronger pull.
Pull-up and Pull-down Resistors: These resistors set a known voltage level on the GPIO pins. A pull-up resistor pulls the voltage level to high (usually VDD), and a pull-down resistor pulls it to low (usually GND).
High-Z (High Impedance): When a GPIO pin is disconnected, it's neither high nor low but is in a floating state. This state is often called "High-Z."
How It Works
Using Internal Pull-Up: The firmware configures an internal pull-up resistor and reads the GPIO input. If it reads high, proceed to the next step.
Switch to Internal Pull-Down: The firmware changes to an internal pull-down resistor and reads the GPIO input again. If it reads low, it's confirmed that the state is High-Z.
External Strong Pull-Up/Pull-Down: If an external resistor is connected to either VDD (for pull-up) or GND (for pull-down), following the same procedue as above, the GPIO will read consistently high or low, respectively. This is because the strong external resistor will overcome the weak internal resistor.
Mathematical Insight
The number of configurations N is given by: N=3^n
For two GPIOs, you have 9 configurations.
Best Use Case
Ideal for development boards with ample space for external components.
Conceptual Basics
High and Low States: Each ID position allows two states: high and low.
How It Works
Each hardware ID GPIO is intilized with internal pull up at boot.
Read the GPIO. A 'floating' GPIO reads as high; a 'shorted' GPIO reads as low.
Mathematical Insight
The number of configurations N is: N=2^n
For two GPIOs, you have 4 configurations.
Best Use Case
Perfect for devices with small form factors like wearables.
Conceptual Basics
EEPROM with OTP ID: EEPROM (Electrically Erasable Programmable Read-Only Memory) often features a One-Time Programmable (OTP) section. This section can be permanently configured either by the user or during the manufacturing process. This unique feature of EEPROM is what makes this advanced HWID method viable. As a result, each PCBA can be programmed with a unique HWID at the factory during manufacturing, allowing for individual identification across different prototype designs.
How It Works
Programming OTP ID: During the manufacturing process, a unique ID is programmed into the OTP section of the EEPROM. This typically occurs at the SMT (Surface-Mount Technology) line.
Bootloader Reads ID: When the device boots up, the bootloader firmware reads the OTP ID from the EEPROM to determine the hardware version or variant.
Configuration Setup: Based on the read OTP ID, the firmware can dynamically configure itself to align with the particular hardware version or variant.
Best Use Case
Ideal when minimal hardware changes are expected and the design release process is thorough, such as in the automobile world.
Note on EEPROM Type
User Options in OTP ID: It's crucial to note that this method can only be employed when the EEPROM used has an OTP ID section designated for user options. Without this specific feature, the approach is not viable.
Method 1: HWID configured with external pull-up/down resistors allows three states: high, low, and high-Z.
Method 2: HWID configured with shorts to ground and each ID position allows two states: high and low.
Advanced Method: HWID configured with unique ID inside Serial Flash or EEPROM can have states more that you need.
By understanding the principles behind each approach, you can make an informed decision that aligns with your project's requirements and limitations.