Selecting a Microcontroller – Part 6: Migration
Dennis Cecic, P. Eng. (d.cecic@ieee.org)
Senior Member, IEEE Toronto Section
You’ve made an MCU choice and are proceeding on a development. What happens if you discover that you need more performance/memory from your MCU? In this final article of the series, we will provide an overview of how to move around the Microchip PIC® MCU product family. There are definitely large portions of the portfolio which are CPU, pinout and peripheral-compatible, easing the transition of your application firmware. We will then provide specific recommendations in migrating from our 3 hero MCUs (PIC16F19197, PIC24FJ1024GA606, PIC32MZ1024EFH064) into other devices.
“Painless” Migration
The following chart organizes 8, 16 and 32-bit PIC MCU devices by functionality and performance:
In general, the easiest code and pin migration will be found by moving within the same instruction set architecture (ISA) family bubble:
- PIC18F devices run at 16 MIPs, and use an enhanced 8-bit CPU which is assembly-language compatible with PIC16F1 CPU but has support for hardware multiply operations and a second HIGH-priority interrupt vector
- dsPIC33E use the same CPU as PIC24F devices and can run up to 70 MIPs. The CPU contains additional hardware for DSP operations.
- For information on migrating between PIC32MX and PIC32MZ applications, see Appendix A, PIC32MZ Data Sheet
Migration Considerations – CPU
Many CPU differences should be taken care of by your compiler, as long as you write code in standard ANSI-C. Using standard C char, float and integral types (defined in “stdint.h“) will definitely help. Make sure to benchmark your main application execution time to verify that it still meets your project requirements. Hardware-specific built-in functions will need to be re-written.
Migration Considerations – Interrupts
As discussed in Part 4 – I/O Throughput, the interrupt controller in PIC24/PIC32 MCUs provides significant operational enhancements which will require updates to your PIC16 interrupt code, such as:
- Dedicated interrupt vector (and handler routine) for each interrupt source
- Programmable interrupt priority and sub priority
- Shadow register set support
Migration Considerations – Clock
A primary consideration when migrating between MCUs is the instruction clock frequency (Fcyc) at a given oscillator frequency (Fosc).
- 8-bit PIC MCUs use Fcyc=Fosc/4
- 16-bit PIC MCUs use Fcyc=Fosc/2
- 32-bit PIC MCUs use Fcyc=Fosc/1
Not only does this effectively double or quadruple the instruction rate at the same input oscillator clock frequency, but also changes the base clock used by many peripherals that utilize the instruction clock as their basis. This frequency change needs to be accounted for when migrating to ensure that peripherals function as expected.
Migration Considerations – Peripherals
There’s a very good chance you’ll need to re-write your peripheral driver code when moving to another MCU family. Having said that, there are huge swaths of 16-bit and 32-bit PIC MCUs that share virtually identical peripheral hardware, minimizing the required changes.
Migration Considerations – Pinout
As mentioned, there is considerable pinout mobility within the ISA family bubbles in the chart above. Review the target MCU data sheet carefully to confirm pinout compatibility!
Moving from the hero MCUs – Some Destinations
Please ensure that you carefully review the target MCU data sheet to assess CPU, Interrupt, Pin and Peripheral compatibility with your current MCU. Here are some suggestions if migrating from our hero MCUs:
PIC16F19197
Same pin-out, same MCU family
- PIC16F1527-I/PT (Supports Hardware Debugger Stopwatch feature, but maximum Fcyc = 5 MIPs, and no peripheral pin select feature (PPS))
- PIC16F1947-I/PT (External Crystal Oscillator option is available, runs at 8 MIPs)
Smaller pin-count, same RAM (4kB), 8 MIPs, has PPS
- PIC16F18877/57 (40/28-pin, 4 kB RAM)
Smallest pin-count, 8 MIPs, has PPS
- PIC16F15313/23 (8/14-pin, $0.50 MCUs with 8 MIPs and PPS)
Same pin-out, higher MIPs and program memory
- Any 64-pin PIC18Fxxx MCU (i.e. PIC18F67J94-I/PT) – 16 MIPs, PPS
PIC24FJ1024GA606
Smaller pin-count, low power, low cost, high integration
- PIC24FJ128GA705/702 (48/28-pin, 16kB RAM)
Similar pin-out (review the data sheet), same CPU core, higher CPU clock (Fcyc)
- PIC24EP256GP206 (64-pin, 32kB RAM, 70 MIPs)
Similar pin-out (review the data sheet), same CPU core, DSP capability
- dsPIC33EP256GP506 (64-pin, 32kB RAM, 70 MIPs)
In all these cases, the target peripheral set should be carefully reviewed to evaluate application suitability and effort for porting the code.
PIC32MZ1024EFH064
This MCU is almost at the pinnacle of the PIC MCU portfolio. Here are some directions:
Same pin-out, higher CPU clock speed (Fcyc), higher program memory
- PIC32MZ2048EFH064 (252 MHz, 2MB Flash)
Higher pin count (more digital/analog I/O):
- PIC32MZ2048EFH144 (252 MHz, 144-pins)
- PIC32MZ2048EFM144 (200 MHz, 2MB Flash, 144-pins, CAN Bus, Crypto Module, Random Number Generator)
If you need low pin count, PIC32 device, consider PIC32MX family devices (based on MIPS M4K core)
- PIC32MX170F256B/D (28/44-pin, up to 50 MIPs)
There is no real “low power” variant for this family, suitable for long duration, battery-powered applications. Consider migrating to PIC24F MCUs.
Migration Guides
PIC32MX to PIC32MZ – See Appendix A, PIC32MZ Data Sheet
Microchip 8-bit to 16-bit Migration Page
Microchip PIC18F to PIC24F Migration Guide