Log in

View Full Version : Compiling problem



Galaxy76
- 24th May 2025, 09:22
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

Acetronics2
- 24th May 2025, 11:17
Hi,

Replace your @DEVICE ... lines by



;----[12F629 Hardware Configuration]--------------------------------------------
#IF __PROCESSOR__ = "12F629"
#DEFINE MCU_FOUND 1
#CONFIG
__config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _BODEN_ON & _CP_OFF & _CPD_OFF
#ENDCONFIG


#ENDIF


;----[Verify Configs have been specified for Selected Processor]----------------
; Note: Only include this routine once, after all #CONFIG blocks
#IFNDEF MCU_FOUND
#ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
#ENDIF




and remember to place a



LOW Servoout


just before each PULSOUT command

BTW.

"RCTIME" is " not so good " when reading a pot because of its huge non-linearity ... ( same for the POT command )
would be much better to use the 12F675 ( or 12F1822/1840 ) ADC , here ... :rolleyes:

and overall have a look to that F... Manual ... @DEVICE is something I never saw with PBP ...

" Galaxy 76 " ... French Guy living in the N.O. of France ???

Acetronics2
- 24th May 2025, 11:51
also you can download this one ...

https://support.melabs.com/articles/6151-meconfig

Pretty useful, no ?

Galaxy76
- 24th May 2025, 18:19
Thanks for the help, however i still can't compile. i just want a HEX. i hope someone can post it. thanks

Acetronics2
- 24th May 2025, 20:15
Thanks for the help, however i still can't compile. i just want a HEX. i hope someone can post it. thanks

Strange ...

What IDE do you use and which PBP version ???

here, I tested with MPLAB 8.92 and PBP 3.1.6.4 ( last release )

Ioannis
- 25th May 2025, 13:58
Do you own a legal PBP compiler? Which one?

Ioannis