Dear all,

Due to my limited knowledge on PIC programming. I have found a piece of code that performs as i need it to. However this code is for a 16f628 and i am using a 16f616. This is the piece of code, it is to light up an led once the input voltage has exceeded the internally defined vref:

list r=dec
include "p16f628.inc"
ledbit equ 0
delay10uregister equ 0x20
org 0x00
goto begin
delay10u movlw 10
movwf delay10uregister
count10u decfsz delay10uregister,F
goto count10u
return
setupcmp movlw b'00000010' ; 010 = four i/p muxed + vref
movwf CMCON
bsf STATUS,RP0 ; make sure
bcf STATUS,RP1 ; bank 1
movlw b'00000111' ; RA0:RA2 inputs
movwf TRISA
movlw b'10100110' ; low range, VR3:VR0 = 6
movwf VRCON ; Vref = (6/24) x VDD = 1.25 Volts (VDD = 5 Volts)
bcf STATUS,RP0 ; bank 0
call delay10u
return
begin call setupcmp
bsf STATUS,RP0 ; bank 1
bcf TRISB,0 ; RB0 output
bcf STATUS,RP0 ; bank 0
check call delay10u
btfss CMCON,C1OUT
goto clearledbit
bsf PORTB,ledbit
forever goto check
clearledbit bcf PORTB,ledbit
goto check
end

Now i understand this code completely but need it to work for a 16f616. I beleive the CMCON register above needs to be changed to CM1CON0 for the 16f616. I beleive this to be ok to work in the same way?

Also, on the 16f616 there is no PORTB, however there is a PORTC. Looking at the data sheets for both pics, they have slightly different explanations for their ports. My main question is to you, will i be able to use PORTA on the 16f616 to do the same job as it is doing above, and will i be able to use PORTC to do the job PORTB is doing above? Any explanations to what needs to be changed would be very much appreciated as I am really trying hard to get to grips with pic programming but finding it hard to understand at present.

I hope someone can help

Many Thanks

Jim