PDA

View Full Version : PIC12F683 Pinouts?



cpayne
- 16th March 2006, 22:15
I am trying to write a simple program on a 12F683. Its my first time using a 8 pin PIC. I can't figure out how to do a TRIS. I am not able to get pin GP3 to work as an output and I can't get GP1 to work as an input. I only need AN0, which I have not tested yet. Anyone have any ideas what I'm missing. Code is below. Thanks

@ device INTRC_OSC_NOCLKOUT
@ DEVICE MCLR_OFF ' Master Clear Options

OSCCON = $60 'sets the oscillator speed
DEFINE OSC 4 'Oscillator speed in MHz

' Alias pins
LED_Sig VAR GPIO.3 ' LED - Rx Complete Flag
LED_Rx VAR GPIO.4 ' LED - I2C Data being written
LED_Tx VAR GPIO.5 ' LED - Serial Data Being Read

' Set up Analog
ADCON0 = %11000001 'AN0 Analog, rest digital
ANSEL = %00110001 'AN0 Analog, rest digital
INTCON = %00000000 'all interrupts OFF

' Define used register flags
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50

' Allocate RAM
i VAR BYTE

for i = 1 to 10
high LED_Sig ' LED won't work... It works is I just jumper 5V to the PIN
pause 50
Low LED_Sig
pause 50
High LED_Rx
pause 50
low LED_Rx
pause 50
high LED_TX
pause 50
low LED_Tx
pause 50
next i

start:
if GPIO.1 = 1 then
low LED_Rx
else
high LED_Rx
endif

if GPIO.2 = 1 then 'can't turn the LED off with 5V put right on the PIN
low LED_Tx
else
high LED_Tx
endif
goto start

paul borgmeier
- 16th March 2006, 23:38
Cpayne,

GP3 can only be an input and never output (see datasheet section 4.1)

Add:

TRISIO = 3

to makes GP0(AN0) and GP1 inputs with the rest output (see datasheet section 4.1 again)

Good Luck,

Paul Borgmeier
Salt Lake City, Utah
USA

mister_e
- 16th March 2006, 23:56
also, don't forget to disable the analog comparator...
section 8 of the datasheet...