cancel
Showing results for 
Search instead for 
Did you mean: 

Can running code find out the part number it's running on?

AKrup
Associate II

I'm writing code for STM32F042. If I'm running on the TSSOP20 package, I need to remap PA11 and PA12 to PA9 and PA10. For all other packages, I need to leave them alone.

I can have a compile-time switch and generate different binaries for different packages. Ideally, I'd like to have a single binary. It's only a small difference in code, and I'd like to avoid the potential for confusion about flushing the wrong binary.

4 REPLIES 4

There might be some bits in unique id. Otherwise look if there are bits in OTP you can utilize.

Diff the ROM/OTP and see if anything drops out.​

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Geoffrey1
Associate III

Interesting question. The stm32l4 has a package register defined that can be used to determine the package type, but it doesn't look like the stm32f0 does. However, there are some user definable bytes in the option registers part of flash -- these don't get erased by ordinary flash options. You could "label" the boards with the TSSOP versions by writing something in one of these bytes that your firmware could read. An extra manufacturing step for sure, but might solve your problem

I can also put a version ID resistor on an ADC pin or pull some GPIOs up or down to indicate board version. I was hoping to avoid relying on such out-of-band information :=)

In a way, I prefer encoding the version in the physical board layout. This way hardware features (package type) is encoded in a medium that can only change with hardware changes.

Thank you for the info about the larger chips. I have no experience with them, and it's valuable knowledge that this feature is available on the larger parts.

Sadly, I don't have any of the TSSOP parts or boards to solder them to. The next version of the board may use that package, and I need to decide what, if anything I need to put on the LQFP board to accommodate this future change.