# Basic Wiring :::success - Prior knowledge: - [Breadboard Introduction](https://www.youtube.com/watch?v=_j1oCHseWAc) ::: ## Pickit Appearance ![](https://i.imgur.com/ZXu02oC.png) 5. **Indicator LEDs** of Pickit4 will show on the green line on the pickit4 in the figure. >![](https://i.imgur.com/6mqpZPD.png) 6. **Push Button** of Pickit4 is the black circle on the pickit4 in the figure. ## [TTL](https://zh.wikipedia.org/wiki/%E9%9B%BB%E6%99%B6%E9%AB%94%EF%BC%8D%E9%9B%BB%E6%99%B6%E9%AB%94%E9%82%8F%E8%BC%AF) ![](https://i.imgur.com/DdB1IZg.jpg) > Red: +5V > Black: GND > Green: TXD(transmit data)(used in UART) > White: RXD(receive data)(used in UART) ## Wiring ### PIC18F4520 Pins ![](https://i.imgur.com/tmySAlh.png) ### Pickit-PIC18F4520 Connection ![](https://i.imgur.com/0xw2VxW.png) - Pickit Pin 1 -- PIC18F4520 Pin 1(VPP) - Pickit Pin 2 -- PIC18F4520 Pin 11(VDD) - Pickit Pin 3 -- PIC18F4520 Pin 12(VSS) - Pickit Pin 4 -- PIC18F4520 Pin 40(PGD) - Pickit Pin 5 -- PIC18F4520 Pin 39(PGC) ### ## Example for Testing -- Control one LED ### Wiring - Put the LED on the Pin19(RD0). **Remember to add a resistor to reduce the current.** ![](https://i.imgur.com/b5vRSn5.png) ### Project Setting - Select Tool: Pickit3 or Pickit4 ![](https://i.imgur.com/FOB6Hba.png) - Select Compiler: mpasm ![](https://i.imgur.com/dsFPDCe.png) - New an assembly file and paste the following code ``` #include "p18f4520.inc" CONFIG OSC = INTIO67 ; Oscillator Selection bits (Internal oscillator block, port function on RA6 and RA7) CONFIG WDT = OFF ; Watchdog Timer Enable bit (WDT disabled (control is placed on the SWDTEN bit)) CONFIG PBADEN = OFF ; PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset) CONFIG LVP = OFF ; Single-Supply ICSP Enable bit (Single-Supply ICSP disabled) org 0x00 init: CLRF TRISD ; set PORTD as output CLRF LATD ; 0000 0000 , RD0~RD7 = 0 s1: INCF LATD ; 0000 0001 , RD0 = 1, turn on RD0 NOP end ``` ### Run Project 1. Set up the breakpoint at line `CLRF LATD` and Debug Main Project. **The LED is off now.** ![](https://i.imgur.com/eIigDVU.png) 2. Press F7(step over). **RD0 = 1. The LED is on.** ![](https://i.imgur.com/3L04jKH.png) 3. Modify the LATD to 0x00 in SFRs(You will see the LED is off now.) ![](https://i.imgur.com/v0OedJO.png) ## FAQ ![](https://i.imgur.com/yfeu0hT.png) ## Reference - [Why do we use a USB to TTL converter?](https://www.quora.com/What-is-a-TTL-signal-in-communication-and-when-using-a-USB-port-why-do-we-use-a-USB-to-TTL-converter) - [Pickit 3 User Manual](https://www.sparkfun.com/datasheets/Programmers/PICkit_3_User_Guide_51795A.pdf) - [Pickit 4 User Manual](http://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB_PICkit4_Debugger_UG_DS50002751A.pdf)