# PIC16F684

(Difference between revisions)

## Overview

For a complete list of features, see this printout from the datasheet.

IMPORTANT: See PIC16F684 Registers for detailed information on registers.

### Pinout

Description of Pinout Labels
Label Description
$V_{DD}\,$ + 5 V
$V_{SS}\,$ Ground
$V_{REF}\,$ External Voltage Reference
$RA\#/RC\#\,$ PORTA/PORTC Programmable I/O
$AN\#\,$ A/D Channel
$INT\,$ External Interrupt Input
$P1A/B/C/D\,$ PWM Output

## Configuring I/O

This section shows two sections of code that are used for setting up the I/O of the PIC. The INIT_IO function sets up the ports by setting their default value and their direction. The second function, INIT_ADC sets up the A/D converter.

```INIT_IO
BCF 		STATUS,RP0 		;Bank 0
CLRF 		PORTA 			;Init PORTA - initially set to LOW
MOVLW 	B'000101'			;Set RA<0> as input
MOVWF 		TRISA 			;	and set RA<5:1>
;	as outputs

BSF 		STATUS,RP0 		;Bank 1
CLRF 		PORTC 			;Init PORTC - initially set to LOW
MOVLW 	B'000000'			;Set RC<5:0> as outputs
MOVWF 		TRISC

CLRF		ANSEL			;Set all pins initially to digital I/O
MOVLW	B'000001'
;	RA<5:1> remain digital I/O
RETURN

BCF 		STATUS,RP0 		;Bank 0
MOVLW   B'00000001'			; Set output to left justified
MOVWF   	ADCON0			; Select AN<0> (RA<0>) as input
; Internal Vref

BSF 		STATUS,RP0 		;Bank 1
MOVLW   B'00100000' 		        ;Set Clock TAD to 1.6us (Fosc/32)

RETURN
```

Notice that the two following bits of code are equivalent:

```        CLRF            PORTA
```

and

```	MOVLW 	B'000000'
MOVWF 		PORTA
```