hey folks
currently building the FV-1 project from DIY stompboxes and i'm stuck at the point of programming the 12F683 PIC it uses to convert pot values to pin voltage for the FV-1 program select pins.
i have the code in what i guess is assembly language,
;3 bit glitchless A2D converter
;Version 1 05/09/2011
; __________
; VDD ---| |--- VSS
; ---| 12F683 |--- Bit 0
; CV In ---| |--- Bit 1
; ---|________|--- Bit 2
list P=PIC12F683
#include "P12F683.INC"
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _FCMEN_OFF & _BOD_OFF)
cblock 0x20
new
current
count
endc
org 0
Start:
banksel GPIO
clrf GPIO ;clear GPIO
movlw 07h
movwf CMCON0 ;turn off comparators
banksel TRISIO
movlw b'00010000' ;set pin3 as input rest as output
movwf TRISIO
banksel ANSEL
movlw b'00011000' ;set pin3 as analogue input (AN3)
movwf ANSEL
banksel ADCON0
movlw b'00001101' ;turn on ADC on AN3 left justified
movwf ADCON0
Mainloop:
nop ;wait for a bit
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
banksel ADCON0
bsf ADCON0,GO ;Do ADC
btfsc ADCON0,GO
goto $-1
banksel ADRESH
movf ADRESH,w
movwf new ;write upper 8 bits to new register
swapf new,f ;swap upper and lower bits
rrf new,w ;move 1 step to the right bits 5,6,7 now in positions 0,1,2
andlw b'00000111' ;clear 5 upper bits
movwf new ;write back to new register
subwf current,w ;subtract from current value
skpz ;skip next line if zero ie:- new = current
goto counter ;if new <> current goto counter
movlw b'11111111' ;reset count to 255
movwf count
goto Mainloop ;back to the start
counter:
decfsz count,f ;deduct 1 from count, if count = 0 skip the next line
goto Mainloop ;if count > 0 go back to the start
movf new,w ;if count = 0 move value of new to current
movwf current
banksel GPIO
movwf GPIO ;and send to GPIO
goto Mainloop ;back to the start
end
and i have etched a SOIC adapter with the pickit2 hooked up, and i've installed the MPLAB software, it seems to read the PIC fine. but i have no idea how to compile the hex aside from copying the code into an MPLAB project source folder and hitting 'compile' which.. doesn't work. i don't know if i need to set up the PIC differently first, or am missing some configuration type files, or have the wrong language, or location.
anyone got any advice as to programming these things? i've been kinda slamming my head into various online resources but i lack the knowledge to know where i'm even going wrong and it's pretty overwhelming. my programming knowledge extends to messing around with an arduino briefly. i've been interested in the relay bypass threads and checked out coda effects' great write up but can't seem to apply to this PIC.
i would post in the DIYstompboxes thread but it's already a million pages long and would rather work it out first then post the answer there for any foragers.
many thanks for any assistance! any pointers at all appreciated, my next bet is to start from scratch learning to program some simple LED blink type code onto the PIC to see how it works and then try and sorta reverse engineer the pot conversion code from there.