When developing a product with an 8-Bit PIC® Microcontroller (MCU) there are a few basic design recommendations to consider for any application. The most common are listed in this short summary. Always refer to the device data sheet for specific technical data.
Basic Connection Requirements
Getting started with the PIC 8-bit microcontrollers requires attention to a minimal set of device pin connections before proceeding with development.
The following pins are typically the first to focus on in your design. Each of these will be explained further in this tutorial.
- All VDD and VSS operating voltage pins properly connected to power.
- Master Clear (MCLR) pin connected either internally or externally to VDD supply voltage through a pull-up arrangement.
- OSCI and OSCO oscillator pins properly connected when an external oscillator source is used.
- VREF+/VREF- pins are properly connected to circuitry power and ground when the analog to digital peripherals are used.
- ICSPCLK/ICSPDAT pins used for In-Circuit Serial Programming™ (ICSP™) and debugging purposes are properly isolated.
The minimum mandatory connections are shown.
C2: 0.1 F, 20V ceramic
Power Supply Pins
The use of decoupling capacitors on every pair of power supply pins (VDD and VSS) is required.
Consider the following criteria when using decoupling capacitors:
- Value and type of capacitor: A 0.1 µF (100 nF), 10-20V capacitor is recommended. The capacitor should be a low-ESR device, with a resonance frequency in the range of 200 MHz and higher. Ceramic capacitors are recommended.
- Placement on the printed circuit board: The decoupling capacitors should be placed as close to the pins as possible. It is recommended to place the capacitors on the same side of the board as the device. If space is constricted, the capacitor can be placed on another layer on the PCB using a via; however, ensure that the trace length from the pin to the capacitor is no greater than 0.25 of an inch (6 mm).
- Handling high-frequency noise: If the board is experiencing high-frequency noise (upward of tens of MHz), add a second ceramic type capacitor in parallel to the recommended decoupling capacitor. The value of the second capacitor can be in the range of 0.01 µF to 0.001 µF. Place this second capacitor next to each primary decoupling capacitor.
In high-speed circuit designs, consider implementing a decade pair of capacitances as close to the power and ground pins as possible (e.g., 0.1 µF in parallel with 0.001 µF).
- Maximizing performance: On the board layout from the power supply circuit, run the power and return traces to the decoupling capacitors first, and then to the device pins. This ensures that the decoupling capacitors are first in the power chain. Equally important is to keep the trace length between the capacitor and the power pins to a minimum, thereby reducing Printed Circuit Board (PCB) trace inductance.
- Bulk Capacitor: On boards with power traces running longer than six inches in length, it is suggested to use a bulk capacitor for integrated circuits, including microcontrollers, to supply a local power source. The value of the bulk capacitor should be determined based on the trace resistance that connects the power supply source to the device, and the maximum current drawn by the device in the application. In other words, select the bulk capacitor so that it meets the acceptable voltage sag at the device. Typical values range from 4.7 µF to 47 µF.
The VREF+ and VREF- pins should be treated with the same circuitry protection as the VDD and VSS pins.
The MCLR pin provides two specific device functions:
- Device Reset
- Device Programming and Debugging
The MCLR pin can be shared with a digital input pin on some devices, enabled by the configuration settings. In that case, the MCLR internal circuitry is used.
If programming and debugging are not required in the end application, a direct connection through a resistor to VDD may be all that is required.
During programming and debugging, the resistance and capacitance that can be added to the pin must be considered. Device programmers and debuggers drive the MCLR pin. Consequently, specific voltage levels (VIH and VIL) and fast signal transitions must not be adversely affected. An external capacitor on MCLR may cause issues during device programming or during program execution if Vdd experiences sudden voltage drops.
In-Circuit Serial Programming™ (ICSP™) Pins
The ICSPCLK and ICSPDAT pins are used for In-Circuit Serial Programming (ICSP) and debugging purposes. It is recommended to keep the trace length between the ICSP connector and the ICSP pins on the device as short as possible. If the ICSP connector is expected to experience an ESD event, a series resistor is recommended, with the value in the range of a few tens of ohms, not to exceed 100Ω.
To use the ICSPCLK, ICSPDAT and MCLR pins also as I/O pins, it is best to isolate them from the external circuitry. Simple series resistors of low resistance (≤ 100Ω) will typically work well without affecting the external circuitry operation.
Ri ≤ 100Ω is recommended. Resistance value should be low enough to not affect the external circuit but still isolate the ICSP connections from the application circuitry.
Pull-up resistors, series diodes and capacitors on the ICSPCLK and ICSPDAT pins are not recommended as they will interfere with the programmer/debugger communications to the device. If such discrete components are an application requirement, they should be removed from the circuit during programming and debugging. Alternatively, refer to the AC/DC characteristics and timing requirements information in the respective device Flash programming specification for information on capacitive loading limits, as well as pin input voltage high (VIH) and input low (VIL) requirements.
External Oscillator Pins
Many PIC microcontrollers have options for at least two oscillators—a high-frequency primary oscillator and a low-frequency secondary oscillator. The oscillator circuit should be placed on the same side of the board as the device. Place the oscillator circuit close to the respective oscillator pins with no more than 0.5 of an inch (12 mm) between the circuit components and the pins.
The load capacitors should be placed next to the oscillator itself, on the same side of the board.
Use a grounded copper pour around the oscillator circuit to isolate it from surrounding circuits. The grounded copper pour should be routed directly to the MCU ground. Do not run any signal traces or power traces inside the ground pour. Also, if using a two-sided board, avoid any traces on the other side of the board where the crystal is placed.
Layout suggestions are shown.
In-line packages may be handled with a single-sided layout that completely encompasses the oscillator pins. With fine-pitch packages, it is not always possible to completely surround the pins and components. A suitable solution is to tie the broken guard sections to a mirrored ground layer. In all cases, the guard trace(s) must be returned to ground.
In planning the application’s routing and I/O assignments, ensure that adjacent port pins, and other signals in close proximity to the oscillator, are benign (i.e., free of high frequencies, short rise and fall times, and other similar noise).
Unused Input/Output (I/O) Pins
Unused I/O pins should be configured as outputs and driven to a logic low state. Alternatively, connect a 1 kΩ to 10 kΩ resistor to VSS on unused pins and drive the output to logic low.