Content originally posted in LPCWare by cfbsoftware on Thu Jul 25 01:53:53 MST 2013
Quote: skeeve
With the avr-gcc toolchain,
one could port some code by changing the -mmcu option.
If it didn't port, the process would usually fail before getting an executable.
I note similar options for arm-gcc.
Does the same technique work?
The same technique does work with the ARM gcc compiler. i.e. when compiling for the LPC1347 the option mcpu=cortex-m3 is used but when compiling for the LPC11U the mcpu=cortex-m0 is used.
However that only looks after the difference in instruction sets and would only be sufficient if you were writing code that didn't need to communicate with the outside world.
There are many differences in the way NXP have implemented similar features and peripherals for their different families of microcontrollers. When you are looking for similar examples you need to look for targets where the control of their peripherals (GPIO, pin selection, UART, etc. etc.) have been designed and are organized in a similar way.