Atmega328p and pickit5
To program and debug an ATmega328P (28-pin DIP) on a breadboard using the MPLAB PICkit 5, connect the PICkit 5’s 8-pin Single In-Line (SIL) header to the microcontroller's SPI/ISP pins alongside basic power and decoupling components. [1] (https://onlinedocs.microchip.com/oxy/GUID-8D61C0B9-A97F-4F4D-99F8-1D7424264C2A-en-US-1/GUID-2E07C091-C3CD-4DE3-9187-80FA1E63E969.html), [2] (https://www.phippselectronics.com/how-to-program-an-atmeg328p-standalone-modes-and-wiring/)
- Required Components
• Microcontroller: ATmega328P-PU (28-pin DIP). • Programmer: MPLAB PICkit 5 with male-to-male jumper wires (or an 8-pin header). • Passives: • 1× 10 kΩ resistor (for the RESET pull-up). • 2× 0.1 µF (100 nF) ceramic capacitors (for power decoupling). • (Optional) 1× 16 MHz crystal and 2× 22 pF ceramic capacitors (only needed if you switch from the default 8 MHz internal oscillator to an external clock). [1] (https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard), [2] (https://aherrero.github.io/arduino/iot/2018/09/24/ArduinoToBreadboard.html), [3] (https://www.phippselectronics.com/how-to-program-an-atmeg328p-standalone-modes-and-wiring/)
- Breadboard Power & Reset Setup
Place the ATmega328P across the center ravine of your breadboard and wire the essential support circuitry first: • Power (5V / 3.3V): Connect Pin 7 (VCC) and Pin 20 (AVCC) to the positive (+) power rail. [1] (https://www.phippselectronics.com/how-to-program-an-atmeg328p-standalone-modes-and-wiring/) • Ground: Connect Pin 8 (GND) and Pin 22 (GND) to the negative (-) ground rail. • Decoupling Capacitors: Place one 0.1 µF capacitor between Pin 7 (VCC) and Pin 8 (GND), and a second 0.1 µF capacitor between Pin 20 (AVCC) and Pin 22 (GND) as close to the chip as possible. • Reset Pull-Up: Connect the 10 kΩ resistor between Pin 1 (RESET) and the positive (+) power rail. (Note: Do not put a capacitor on the RESET line when using PICkit 5 ISP/debugWIRE, as it interferes with programming pulses). [1] (https://www.phippselectronics.com/how-to-program-an-atmeg328p-standalone-modes-and-wiring/)
- PICkit 5 to ATmega328P Wiring (ISP)
On the MPLAB PICkit 5, Pin 1 is marked by a small triangle/arrow on the front casing. Note that AVR ISP requires using pins 2 through 7 of the 8-pin connector. [1] (https://www.pololu.com/docs/0J67/5.1), [2] (https://onlinedocs.microchip.com/oxy/GUID-8D61C0B9-A97F-4F4D-99F8-1D7424264C2A-en-US-1/GUID-2E07C091-C3CD-4DE3-9187-80FA1E63E969.html)
PICkit 5 Pin (8-Pin SIL) PICkit 5 Signal ATmega328P Pin ATmega328P Function Pin 1 TVPP / MCLR Not Connected Leave unconnected for AVR ISP Pin 2 VTG / VDD Pin 7 (or + rail) Target Voltage Sense / Power Pin 3 GND Pin 8 (or - rail) Ground Pin 4 MISO (PGD) Pin 18 PB4 (MISO) Pin 5 SCK (PGC) Pin 19 PB5 (SCK) Pin 6 RESET (TAUX) Pin 1 PC6 (RESET) Pin 7 MOSI (TTDI) Pin 17 PB3 (MOSI) Pin 8 TTMS Not Connected Leave unconnected
-
MPLAB X IDE Configuration
-
Create a Project: Open MPLAB X IDE, select Standalone Project, choose ATmega328P as the device, and select PICkit 5 as your hardware tool. [1] (https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/Brochures/MPLAB-PICkit-5-In-Circuit-Debugger-Quick-Start-Guide-50003478.pdf), [2] (https://www.youtube.com/watch?v=_vOkFvMzuyg)
- Powering the Chip: By default, PICkit 5 expects the breadboard to have its own power supply. If you want the PICkit 5 to power the ATmega328P directly (up to 150 mA): • Open Project Properties -> PICkit 5. • Change Option categories to Power. • Check Power target circuit from PICkit 5 and set the voltage level (typically 5.0V for a stock ATmega328P). [1] (https://www.youtube.com/watch?v=_vOkFvMzuyg)
- Programming & Debugging: • Click Make and Program Device to flash via SPI (ISP). • If you click Debug Main Project, MPLAB X will prompt you to enable the DWEN (debugWIRE) fuse, which allows single-wire debugging through Pin 1 (RESET). (Remember to use the "Disable debugWIRE" option in MPLAB before disconnecting if you want to return to standard ISP programming). [1] (https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/UserGuides/MPLAB-PICkit-5-In-Circuit-Debugger-Users-Guide-50003525.pdf), [2] (https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/Brochures/MPLAB-PICkit-5-In-Circuit-Debugger-Quick-Start-Guide-50003478.pdf) Let me know if you need help with: • Setting up external 16 MHz crystal fuse bits • Configuring debugWIRE vs. ISP in MPLAB X • Using Arduino sketches with the PICkit 5