Chris Collins

Tools · embedded

PIC microcontrollers

Pinouts and specifications for 16 popular Microchip PICs from the PIC10F200 to the PIC18F45K22, a configuration-bits generator and decoder (XC8, pic-as, MPASM), timer, PWM, baud-rate, I²C and A/D clock calculators, a PIC16F84A assembler and simulator with LEDs, buttons and a 7-segment display, and an Intel HEX inspector.

Added

How to use it

Everything runs in your browser. The tabs:

  • Chips & pinouts — PIC10F200/202, PIC12F629, PIC12F675, PIC12F683, PIC12F1840, PIC16F84A, PIC16F628A, PIC16F88, PIC16F877A, PIC16F1827, PIC16F1847, PIC16F18446, PIC18F2550, PIC18F4550, PIC18F25K22 and PIC18F45K22, each drawn as its DIP package with every pin’s functions, memory sizes, peripherals, oscillator options and a link to the data sheet. The pin names are taken from each data sheet’s pin diagram. For the enhanced mid-range and K22 parts the data sheets' diagrams show port names only — their peripherals can move between pins (APFCON, or Peripheral Pin Select on the PIC16F18446) — so the page points you to the pin allocation table instead of guessing.

  • Configuration bits — choose the oscillator, watchdog, power-up timer, MCLR, brown-out, low-voltage programming and code protection settings for the PIC16F84A, PIC16F628A, PIC12F629, PIC12F675, PIC12F683, PIC16F877A or PIC16F88, and copy the result as XC8 #pragma config lines, pic-as CONFIG lines, or an MPASM __CONFIG word. Paste a configuration word to decode it. Each setting’s value is the word with that field set and every other bit 1, so the configuration word is all the settings ANDed together — exactly how MPASM’s _XT_OSC & _WDT_OFF & … works. The settings and values come from Microchip’s device files as published in the gputils device help.

  • Timing — the instruction cycle (Fosc ÷ 4); the best Timer0 prescaler and preload for a period (period = 4/Fosc × prescaler × (256 − preload)); Timer1 and Timer2 (with PR2 and the postscaler); CCP PWM — PR2, the 10-bit duty value split into CCPRxL and DCxB, and the resolution, log₂(4 × (PR2 + 1)); UART SPBRG/SPBRGH for BRGH and BRG16 with the baud error; I²C SSPADD = Fosc ÷ (4 × SCL) − 1; and the fastest valid A/D clock for a minimum TAD.

  • Assembler & simulator — write MPASM-style assembly for the PIC16F84A and run it. Pick an example (LED blink, button to LED, Timer0 interrupt blink, 7-segment counter), then Step, Step over, or Run in real time at your clock frequency. Click a listing line for a breakpoint. The pins panel shows PORTA and PORTB as LEDs; click an input pin to drive it high or low (a button), and tick the 7-segment view to see RB0–RB6 as segments a–g. Registers, STATUS/INTCON/OPTION bits, the stack, the 68 bytes of RAM and the EEPROM update as it runs, with a cycle counter and stopwatch. Download .hex gives an INHX8M file you can program with a PICkit.

  • HEX inspector — open a .hex from MPLAB, XC8, gpasm or this page: program words, the configuration word decoded for a chosen device, ID locations, EEPROM data at 0x2100, and a disassembly. A program that fits in 1K words opens in the simulator.

The assembler and simulator

The assembler understands labels, EQU, SET, CBLOCK/ENDC, ORG, END, __CONFIG and CONFIG, DT (RETLW tables), DE (EEPROM data), DW, #define, BANKSEL, PAGESEL, HIGH/LOW, $, and the MPASM number forms 0x1F, H'1F', 1Fh, D'31', .31, B'00011111' and 'A'. As in MPASM, a bare number is hexadecimal unless you write LIST R=DEC or RADIX DEC, and an operand with a bank-1 register address (CLRF TRISB) keeps only its low 7 bits, with a warning to check the bank bits. A built-in p16f84a.inc provides the register, bit and configuration names. Symbols are case-insensitive here; MPASM is case-sensitive by default.

The simulator models the PIC16F84A’s core and its 35 instructions with their flags and cycle counts, the two RAM banks (0x0C–0x4F shared), indirect addressing, the 8-level stack, Timer0 with its prescaler (and the two-cycle pause after writing TMR0), RB0/INT and RB4–RB7 change interrupts, the PORTB pull-ups, RA4’s open-drain output, SLEEP and the EEPROM read and write sequence. It does not model the watchdog timeout, oscillator start-up, or analogue and electrical behaviour.

Sources

The pinouts, memory sizes and peripherals come from Microchip’s data sheets: PIC10F200/202/204/206 (DS41239), PIC12F629/675 (DS41190), PIC12F683 (DS41211), PIC12(L)F1840 (DS40001441), PIC16F84A (DS35007), PIC16F627A/628A/648A (DS40044), PIC16F87/88 (DS30487), PIC16F87XA (DS39582), PIC16(L)F1826/27 (DS41391), PIC16(L)F1847 (DS40001453), PIC16(L)F18426/46 (DS40001985), PIC18F2455/2550/4455/4550 (DS39632) and PIC18(L)F2X/4XK22 (DS40001412). The instruction encodings and the configuration word layout are the PIC16F84A data sheet’s (Table 7-2, Register 6-1); see also the PICmicro Mid-Range MCU Family Reference Manual (DS33023).

Runs entirely in your browser; nothing you type leaves this page.