PDA

View Full Version : Help with this code, it compiles but doesn't work on my simulations



joseph
- 6th April 2010, 15:48
@ DEVICE pic12F683, INTRC_OSC_NOCLKOUT
DEFINE OSC 8
TRISIO = %101011
CMCON0 = 7
start: IF GPIO.1 = 1 then
high GPIO.4
alarm: FREQOUT GPIO.2,1500,1000
pause 1500
goto alarm
else
low GPIO.2
pause 100
low GPIO.4
pause 100
goto start
endif
end



this code compiles, i'm sure that i selected the correct device but it doesn't work :(

Dave
- 6th April 2010, 18:26
joseph, What makes you think it doesn't work? The statememts you have here:
alarm: FREQOUT GPIO.2,1500,1000
pause 1500
goto alarm
will loop forever..... Not a very good practice...

Dave Purola,
N8NTA

joseph
- 6th April 2010, 18:27
Help :confused:

malc-c
- 6th April 2010, 18:40
Try adding:

ANSEL = 0 ' Analog select set to digital, pg 69 data sheet
ADCON0 = 0 ' A/D turned OFF, pg 68 of data sheet

Also, have you used a 10K resistor to pull down GPIO.1 so it reeds logic 0 until the switch is pressed and GPIO.1 is taken high

joseph
- 6th April 2010, 18:43
i'l try to add that and regarding the pull down yes i did placed a pulldown resistor

joseph
- 6th April 2010, 18:47
whoa! it worked! :D:D:D thankyou malc-c

malc-c
- 6th April 2010, 19:27
I'm not going to hammer on about how you must read the data sheets for these devices, I'll leave that to some of the others :)

Glad to of helped.