Hello, I have this code, but I can't compile it. I always get error. Could someone please compile it and post the hex file here? Thanks
sorry for my english.
@ DEVICE pic12F629, INTRC_OSC_NOCLKOUT ; Using Internal Clock, no clock out
@ DEVICE pic12F629, WDT_ON ; Enable Watch dog timer
@ DEVICE pic12F629, PWRT_ON ; Enable Power-up timer
@ DEVICE pic12F629, MCLR_OFF ; Disable MCLR pin
@ DEVICE pic12F629, BOD_ON ; Enable Brown-out detect
@ DEVICE pic12F629, CPD_OFF ; EEPROM Protect
@ DEVICE pic12F629, PROTECT_OFF ; Code Protect off
TRISIO = %11111110
INTCON.6=0 ' Disable all unmasked Interrupts
INTCON.7=0 ' Disable Global Interrupts
CMCON = 7 ' Disable analog comparator
ServoOut var GPIO.0
SetLimitSw var GPIO.1
PotIn var GPIO.2
MinSw var GPIO.4
MaxSw var GPIO.5
wPosit var word
Posit var byte
MinPosit var byte
MaxPosit var byte
'load starting min and max positions
data @ 0, 100
data @ 1, 250
'************************************************* ***************
low Servoout
'read in stored min and max limits
read 0, MinPosit
read 1, MaxPosit
'for power-on reset of positions:
if minsw = 1 then
minposit = 100
write 0, minposit
endif
if maxsw = 1 then
maxposit = 250
write 1, maxposit
endif
pause 1000
Start:
gosub GetServoPosition
pulsout servoout, posit
pause 20
if setlimitsw = 1 then 'check min max buttons
if minsw = 1 then
MinPosit = Posit
write 0, MinPosit
pause 250
endif
if maxsw = 1 then
MaxPosit = Posit
write 1, MaxPosit
pause 250
endif
endif
goto start
'************************************************* ***************
GetServoPosition:
high potin
pause 1
rctime potin, 1, wPosit 'at 4 mhz, returns 0 - 120
'adjust posit to get values between 75 and 250
'use word-sized variable because calculation might exceed 255
wposit = wposit + 75 + (wposit / 2)
'now limit posit to 100 - 250 (1 ms - 2.5 ms)
'and put into byte-sized variable
if wposit > 250 then
posit = 250
else
posit = wposit
endif
if posit < 100 then posit = 100
if setlimitsw = 0 then 'apply limits
if Posit < MinPosit then Posit = MinPosit
if Posit > MaxPosit then Posit = MaxPosit
endif
return
'************************************************* ***************
End
Bookmarks