Electronic – PIC24 Debugging

debuggingpic

I'm in the process of figuring out what sub-model of PIC24 best suits my needs and I'm wondering if debugging the MCU takes up a UART module. The MCU will need to communicate with a LIN transceiver and a Bluetooth module, both via UART, so I need to know if two UART modules will be enough or if I should spring for an MCU with 4 UART modules.

Best Answer

In-circuit debugging works over the same dedicated pins that programming does. Just like a programmer, a debugger connects to power, ground, MCLR, and the programming clock and data lines. These used to be called PGC and PGD, respectively, but lately there have been variants on those names. Of course this is all in the datasheet.

On some parts, the PGC and PGD lines can be re-purposed at run time as I/O or other functions. You can't do that during debugging. For that reason, it is good to reserve these two lines for programming and debugging.

If you really need those two extra lines in your production board, then you can make debug boards with the next larger PIC in the family. Now PGC and PGD can have their dedicated functions, and you take the extra two I/O pins from the additional pins of the larger PIC. With proper firmware discipline, switching between the debug and production systems is trivial.

Another issue to consider is crosstalk between PGC and PGD. Unfortunately, the pinout of the standard cable used by the RealIce and the like puts these two lines adjacent to each other. This is one reason my PIC programmers have optional connections with a ground line between PGC and PGD. For more details on this issue, take a look at my In-Circuit Serial Programming writeup.