Electronic – a good way for the mcu to determine which hardware version it is running on


I'm working on a new product design and there will probably be small or large hardware changes/fixes over the life of the product. For future firmware updates in the field I need a way to determine the hardware revision. What is a good strategy?

I'm currently pulling two spare pins up/down with external resistors and checking the pattern. This only allows for 4 hardware revisions, but that might be enough for practical purposes. It might become a problem if I need one or both of those pins in a future hardware revision.

I guess a more economical way might be to have a resistor divider connected to an ADC pin. Each hardware revision could have different value resistors. Unfortunately I don't have any spare ADCs in my current design.

I guess another way could be to encode the hardware version number in an EEPROM or the mcu flash during production? (We don't have that facility at the moment.)

I guess I'm looking for suggestions for a flexible and robust method.


Re. suggestion from @trav1s: I don't have an address bus per se but I have an 24LCxx EEPROM on the I2C bus. The low 3 bits of the Slave Address is hardwired. I guess I could change the address bits and search for the EEPROM during startup.

Best Answer

This is something I deal with on an ongoing basis. We have very complex hardware that's been in the field for almost 10 years, with different versions of various subsystems. Some of the subsystems have a 2-bit code, but as you mentioned, that's not always enough.

The EEPROM suggestion is a good one, but it requires programming the EEPROM and populating the board with the right version.

What I would suggest is an 8-bit parallel in-serial out shift register like a 74HC166. The version number can be set on the input by the PC board itself tying inputs HIGH or LOW and then you only need 3 pins to load and read the shift register from an MCU.