Microchip PIC24

 

javaw_2017-08-13_19-37-56.png
Here’s what MPLAB X looks like with the processor halted when the code was compiled with -O1. Note that even the disassembly view is empty — this is absolutely unheard of in any microcontroller architecture reviewed.

Debugging Experience

The moment you turn the optimizer on, you can no longer debug code on the PIC24. I don’t mean “it’s a lot harder, because you jump around a lot” — no, it’s actually flat-out impossible. The disassembly view is totally blank, and the C source view doesn’t even attempt to determine where it is — it’s as though the compiler builds the program without any debugging metadata in the binary file. I didn’t experience anything like this with the PIC16 (which uses Microchip’s XC8 compiler), or the PIC32 (which uses the GCC-based XC32 compiler similar to the PIC24’s XC16)

Performance

Bit-wiggling was not good — with the optimizer off, the PIC24 took 10 clock cycles to toggle a pin. With the optimizer on, I could actually look at the 14-cycle chunk of code it emitted:

0x350: MOV LATA, W0
0x352: LSR W0, #2, W0
0x354: AND.B W0, #0x1, W0
0x356: BTG.B W0, #0
0x358: AND.B W0, #0x1, W0
0x35A: ZE W0, W0
0x35C: AND W0, #0x1, W0
0x35E: SL W0, #2, W0
0x360: MOV LATA, W1
0x362: BCLR W1, #2
0x364: IOR W0, W1, W0
0x366: MOV W0, LATA

Icky.