Overview

The PIC16F628A is an 18-pin Flash-based 8-bit CMOS microcontroller manufactured by Microchip Technology. Available in a DIP-18 through-hole and SOIC-18 package, it was engineered as the direct modernized drop-in replacement for the legendary PIC16F84A.

Operating from 2.0V2.0\text{V} to 5.5V5.5\text{V} DC at up to 20 MHz20\text{ MHz} (or via its internal 4 MHz4\text{ MHz} calibrated RC oscillator without external crystals), the PIC16F628A vastly outperforms the older 16F84A by providing double the Flash memory (2K words/3.5 KB2\text{K words} / 3.5\text{ KB}), more than triple the RAM (224 Bytes224\text{ Bytes}), double the EEPROM (128 Bytes128\text{ Bytes}), a full addressable hardware USART (RX/TX), dual analog comparators with programmable internal voltage reference (VREFV_{REF}), and a Capture/Compare/PWM (CCP) module. It is a workhorse for hobbyist digital clocks, frequency counters, and serial display modules.

Quick reference

CPU Core8-bit PIC Mid-Range RISC (35 instructions)
Package18-pin DIP (DIP-18 / PDIP-18) / 18-pin SOIC / 20-pin SSOP
Max Clock Frequency20 MHz20\text{ MHz} (4 MHz4\text{ MHz} factory internal RC)
Flash Program Memory2048 words (3.5 KB3.5\text{ KB}, 14-bit words)
Data RAM224 bytes
Data EEPROM128 bytes
Operating Voltage (VDD)2.0 V2.0\text{ V} to 5.5 V5.5\text{ V} DC (3.0V5.5V3.0\text{V} \dots 5.5\text{V} for 20MHz20\text{MHz})
GPIO Count16 I/O pins (Ports A and B)
Hardware USARTFull duplex addressable USART (RB1/RX, RB2/TX)
Analog Peripherals2x Analog Comparators + Programmable internal VREFV_{REF} module
Timers / PWM3 Timers (Timer0/1/2) + 1x CCP module (10-bit PWM)

Pinout (DIP-18 Package)

text
                            ┌───┴───┐
      (AN2/VREF)      RA2  1│ 1   18│ RA1 (AN1)
      (AN3/CMP1)      RA3  2│       │17 RA0 (AN0)
      (T0CKI/CMP2)    RA4  3│       │16 RA7 (OSC1/CLKIN)
      (Active-Low)   RA5/ 4│PIC16F │15 RA6 (OSC2/CLKOUT)
                 MCLR/VPP   │ 628A  │14 VDD (+5V)
                      VSS  5│DIP-18 │13 RB7 (T1OSI/PGD)
              (INT)   RB0  6│       │12 RB6 (T1OSO/T1CKI/PGC)
             (RX/DT)  RB1  7│       │11 RB5
             (TX/CK)  RB2  8│       │10 RB4 (PGM)
             (CCP1)   RB3  9│       │9  (Center-notch bottom)
                            └───────┘
PinNameTypeDescription
1, 2RA2, RA3GPIO / AnalogAN2 / VREF / AN3 / Comparator 1 Input
3RA4GPIO / DigitalTimer0 Clock Input T0CKI / Open-drain output
4RA5 / MCLRDigital InputActive-LOW Reset / VPP / General Input
5VSSPowerCommon Ground reference (0 V0\text{ V})
6RB0GPIO / DigitalExternal Interrupt INT / PCINT
7RB1GPIO / DigitalHardware UART Receive RX / Data DT
8RB2GPIO / DigitalHardware UART Transmit TX / Clock CK
9RB3GPIO / DigitalCapture/Compare/PWM Output CCP1
10, 11RB4, RB5GPIO / DigitalPort B GPIOs / Low-Voltage ICSP PGM
12RB6GPIO / DigitalIn-Circuit Serial Programming Clock PGC / T1CKI
13RB7GPIO / DigitalIn-Circuit Serial Programming Data PGD / T1OSI
14VDDPowerPositive Supply Voltage (+2.0 V+2.0\text{ V} to +5.5 V+5.5\text{ V})
15, 16RA6, RA7GPIO / ClockOSC2/CLKOUT and OSC1/CLKIN (usable as GPIO with internal RC)
17, 18RA0, RA1GPIO / AnalogAN0, AN1 / Comparator Inputs

Comparison: PIC16F628A vs PIC16F84A

ParameterPIC16F628APIC16F84A
Pinout / SocketIdentical DIP-18Identical DIP-18
Internal OscillatorYes (4 MHz4\text{ MHz} calibrated RC)No (Requires crystal or RC network)
Flash Memory2048 Words2048\text{ Words} (3.5 KB3.5\text{ KB})1024 Words1024\text{ Words} (1.75 KB1.75\text{ KB})
Data RAM224 Bytes224\text{ Bytes}68 Bytes68\text{ Bytes}
Hardware USARTYes (Pins RB1/RB2)No (Software Bit-Bang Only)
Timers / PWM3 Timers + CCP (PWM)1 Timer (Timer0 only, no PWM)

Common mistakes

  • PORTA analog comparator defaults: On power-up, PORTA pins default to analog comparator inputs. To use PORTA as general digital I/O, write CMCON = 0x07; at the beginning of the program to turn off the comparators.
  • Pin RA4 open-drain behavior: Pin 3 (RA4) has an open-drain output. When driven HIGH, it floats; it requires an external pull-up resistor to output a logic HIGH voltage.

Notes

  • Programming: Compatible with PICkit 2, 3, 4, SNAP, and standard ICSP programmers using MPLAB X IDE and the XC8 compiler.

Assets & downloads