Difference between revisions of "PIC16F684"

From Mech
Jump to navigationJump to search
Line 33: Line 33:
==Configuring I/O==
==Configuring I/O==


<pre>
INIT_IO
BANK0
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
BANK1
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'
MOVWF ANSEL ;Set AN<0> (RA<0>) to Analog input
; RA<5:1> remain digital I/O
RETURN
</pre>


==Setting Up for PWM Output==
==Setting Up for PWM Output==

Revision as of 17:52, 11 July 2006

Overview

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

IMPORTANT: See PIC16F684 Registers for detailed information on registers.

Pinout

Pic16f684 pinout.png
Description of Pinout Labels
Label Description
+ 5 V
Ground
External Voltage Reference
PORTA/PORTC Programmable I/O
A/D Channel
External Interrupt Input
PWM Output

Initialization

Configuring I/O

INIT_IO	
	BANK0
	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
	BANK1
	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'
	MOVWF		ANSEL			;Set AN<0> (RA<0>) to Analog input
								;	RA<5:1> remain digital I/O
	RETURN

Setting Up for PWM Output