12F683 - Pin1 not working
Hi there,
i was planning on hacking a small static toy car from my son and place inside a pic and some leds to give it some life.
I have a couple of 12f683 pics around so i decided to use them for this.
I started with a simple combination of lights to check the effects and go from there but something stopped me.
I can explain why but GPIO.1 does not respond to commands.
I can put any of the pins to work except pin 1 ( turnsign ).
I tried both pics and both have the same behavior.
Maybe some wrong define or something i'm not seeing but it's killing my brain's out.
Here is the code:
Code:
'PINS
speaker var GPIO.5
stops var GPIO.4
BUT var GPIO.3
bottom var GPIO.2
turnsign var GPIO.1
headlights var GPIO.0
'*****************************************************************************
OSCTUNE=%00000000 ' calibrated frequency
DEFINE OSC 8
'*****************************************************************************
@ DEVICE pic12F683, INTRC_OSC_NOCLKOUT
@ DEVICE pic12F683, WDT_OFF
@ DEVICE pic12F683, PWRT_OFF
@ DEVICE pic12F683, MCLR_OFF
@ DEVICE pic12F683, BOD_ON
'*****************************************************************************
'HPWM
DEFINE CCP1_REG GPIO
DEFINE CCP1_BIT 2
'*****************************************************************************
ADCON0=0
ANSEL=0
CMCON0=7 'only for 12F683 - comparator off
OPTION_REG.7=1 ;disable Pull-Ups
TRISIO=%001000 ;set GPIO3 as input
OSCCON=%01110111 ' 8mHz clock define
CCP1CON=0 ' 12F683 ccpm module off
INTCON=0 'interrupt control register
'WPU=0
'PIE1=0
'PIR1=0
'T1CON=0
'T2CON=0
GPIO=0
'*****************************************************************************
va var byte
va2 var byte
km var word
mem1 var byte
value var word
steps VAR WORD
eep1 con $10
'*****************************************************************************
sense:
if but=1 then
mem1=1
write eep1,mem1
goto all
endif
init:
high turnsign
sound gpio.5,[50,10]
pause 100
low turnsign
pause 150
high turnsign
sound gpio.5,[50,10]
pause 100
low turnsign
pause 500
inp:
if but=1 then
mem1=mem1+1
endif
if mem1>12 then
mem1=1
endif
write eep1,mem1
return
all:
high headlights
high stops
low turnsign
low bottom
sound gpio.5,[50,10]
pause 500
low headlights
low stops
high turnsign
high bottom
sound gpio.5,[50,10]
pause 500
goto all
Thanks
Re: 12F683 - Pin1 not working
Just one thought ruijc
Since your trying to troubleshoot the functionality of a pin to a particular device (perhaps an LED) , why not consider reducing down to the lowest level?
Create a program to control that one device and nothing more.
You can swap the code and wiring from gpio.0 to gpio.1 to see if the device is acting differently. That would allow you to verify if the issue is hardware vs code.
In some cases, I have had to sink a device rather than source it due to current limitations on the PIC. Hope that helps. :-]
Re: 12F683 - Pin1 not working
The original post is dated more than 5 years ago. I suspect his son is old enough to help figure out what is wrong by now. :)