UPGRADING FROM PIC16F84 TO PIC16F628
If you are upgrading from a PIC16F (or C) 84 (A), the pinout is below. Note all the port pins are in the same positions on both chips. Port B is identical. Port A on the PIC16F84 has 4 in/out and 1 "input and "half-output". The PIC16F628 has 6 in/out, one "input and half-output" (RA4) and 1 input only (RA5).
The thing you have to remember is:
On both the PIC16F84 and PIC16F628, RA4 is an "input and half-output". When used as an output, these pins will only sink 25mA and source 0mA. To make the pin source, connect the base of a transistor to the pin and put the transistor in emitter-follower mode by connecting the collector to the positive rail as in the diagram below. RA5 on a PIC16F628 is input only.
MAKING RA4 SOURCE A CURRENT RA4 will not deliver a current to a load. To make it deliver a current, the following circuit can be used. Place a 2k2 on the base, to positive. When the pin is HIGH (or as an input) the emitter will source (deliver) 25mA (or more) as the base is being pulled HIGH by the 2k2. The current via the emitter is equal to the base current multiplied by the gain of the transistor. When the output of the micro is LOW, the base will be pulled low by the pin and the emitter will be low. The circuit below will not allow for sinking a current. But it makes the pin source just like the other outputs. Don't forget, the maximum current for the chip, via all the pins is less than 250mA, to prevent overheating.
Note: the first temporary storage file for PIC16F84 is 0Ch. Note: the first temporary storage file for PIC16F628 is 20h.
Then add these instructions just before the first two instructions in your code to disable the on chip comparator -
Code:
org 0x000 ;reset vector
goto START
START movlw 0x07 ;disable on chip comparator
movwf CMCON
;rest of code goes here
Everything else should be the same. Setting up the config word as shown above and disabling the comparator essentially makes it the same as a 16F84A so nothing else should be needed unless you decide to use some of the F628A's on chip peripherals.