16
\$\begingroup\$

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.

[EDIT]

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.

\$\endgroup\$

4 Answers 4

9
\$\begingroup\$

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.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I like that the hw version is hardwired on the board, that way I need only one firmware version and I don't need to handle preprogrammed EEPROMs. Looks like a shift register can be found for about USD 0.1 and that is OK. \$\endgroup\$
    – morten
    Sep 20, 2012 at 18:23
  • 3
    \$\begingroup\$ Along those same lines, you could also use an I2C port expander hanging off of your I2C bus. It may be a bit more expensive, though. \$\endgroup\$ Dec 14, 2013 at 7:08
8
\$\begingroup\$

I wouldn't use a version number programmed into the microcontroller. Unless the software is different for different board versions, but then the board version seems superfluous to me. Have as few versions of the microcontroller's software as possible, ideally just one. Each different version may cause logistic problems.

The EEPROM code is a good idea, because it allows for lots of different board codes, but take it out of the microcontroller, in a separate device. EEPROM is expensive for large capacities (much more expensive per bit than Flash), but for a few bytes you can find them cheap. This one is only 16 cents in 100s and only needs 1 I/O line.

A way to decrease the chance of errors is to have a different package for each board version. So have a batch of EEPROMs programmed with a version number 1 in SOT-23, the next version 2 in MSOP, etc. Then you can't have a version 1 EEPROM on a version 2 board.

\$\endgroup\$
2
  • \$\begingroup\$ Thx. This may be a stupid question, but how do I get a batch of EEPROMs programmed prior to putting them on the board? I don't have the facility to take the EEPROMS off the tape, program them, put them back on tape and send the tape to the PCB assembler. \$\endgroup\$
    – morten
    Sep 20, 2012 at 8:56
  • \$\begingroup\$ @morten - Your supplier can do that for you. You send them your file (that one byte :-)) and you get the parts programmed back, marked with a marking of your choice. Cost will depend on batch size; you'll have a fixed cost + a cost per part. We once calculated if it wouldn't be cheaper to do the programming ourselves, but in any case for thousands it wasn't worth it. \$\endgroup\$
    – stevenvh
    Sep 20, 2012 at 9:03
6
\$\begingroup\$

One option that will use only two digital pins is something like this:

Circuit diagram

By changing the R1 and C1 values you can have different charge times for the capacitor that you can measure to determine the hardware version.

\$\endgroup\$
1
  • \$\begingroup\$ Aha, pretty clever solution :-) \$\endgroup\$
    – morten
    Sep 20, 2012 at 18:43
2
\$\begingroup\$

If there is any unused space on in the address bus you could place a ROM register on the bus which can be read by the MCU. The register would contain the version number of the hardware. When the MCU reads from that address the register would write its value to the data bus. The register could be hardwired on the board or if you want to be able to change the version number with your bare hands you could make pins that can be tied up/down like you are doing now.

\$\endgroup\$
2
  • \$\begingroup\$ Maybe I could use the address of the EEPROM itself... see edit to question. \$\endgroup\$
    – morten
    Sep 20, 2012 at 8:31
  • \$\begingroup\$ OK. Didn't know there was an I2C bus. Maybe you could just make a tiny I2C slave which reads back the version number when the MCU reads from it. \$\endgroup\$ Sep 20, 2012 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.