ruijc
- 23rd January 2009, 21:49
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:
'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
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:
'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