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.
-
3\$\begingroup\$ PIC debugging does not require a UART. However, you'll need to check that the pins used for debugging (PGC/PGD) on the particular PIC you choose aren't used by some other function which you require. \$\endgroup\$– brhansCommented Jun 4, 2018 at 21:26
-
4\$\begingroup\$ I would reserve one UART for debugging/logging in any case. \$\endgroup\$– Eugene Sh.Commented Jun 4, 2018 at 21:27
-
\$\begingroup\$ Thanks -- I'll err on the side of caution and go with an MCU with >= 4 UART modules. \$\endgroup\$– t3ddftwCommented Jun 4, 2018 at 22:19
2 Answers
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.
No, it doesn't. There is no need to reserve a UART for debugging if you have a debug tool like PICKIT.
If you don't have then buy one, it helps a lot
The UART ports can be attached to any PPS capable pins so you can avoid conflicts with the debugger port.