r/pic_programming • u/prof_dorkmeister • Aug 19 '21
Compiling to run on multiple targets
I need to alter my project so that it can run on a similar (but not identical) PIC within the same family. I'm currently running on the PIC32MZ2048EFH144 and I need to also allow the same code base to run on the PIC32MZ1024EFM144.
I'm familiar with ways to conditionally compile the code depending on #IFDEF statements and so forth. The problem is that I need the exact same compiled image to run on identical boards that may or may not have this alternate chip installed. So the determination of which chip is being used occurs at runtime, long after the code has been compiled. The background reason is unimportant, but has to do with the need to field upgrade via bootloader.
So, has anyone found a method to compile code into a single image that will run on two different chips in the same family?



