Hi,
The only config that has any actual impact on the oscillator would be the first one, the others have impact on other things but has nothing to do with the oscillator. In either case they look fine to me but if you want to set them from within your code you need get the naming correct, if you set them manually thru your programmer software it doesn't matter. If you have PBP3 I strongly suggest you open the DEVICE REFERENCE folder in the PBP3 installation directory and then open the PIC16F628.INFO (it's a plain text file). It shows you what default CONFIG PBP will use if you don't tell it otherwise and it shows you how to set whatever you want - in the code so you don't have to mess around with it in the programmer software.
As for CMCON, open the datasheet (please use this one so we're looking at the same thing) and browse to the comparator section. Look at the description of the CMCON register and you'll see that bits 0-2 controlls the comparator mode with a note that figure 9-1 shows the various modes. Now flip the page to find figure 9-1 and find the one that suits you ie. both comparators off and you'll see that in order to do that bits 0-2 should be set - therefor CMCON = 7.
On the 16F628 you can't really set the frequency of the internal oscillator, you can switch it between 32kHz and 4MHz (I guess that's what you meant though) and that's done by clearing (32kHz) or setting (4MHz) the OSCF bit in the PCON register. If you look at the PCON register in the datasheet you'll see that the OCSF bit is bit 3 (not bit 2 which you seem to have in your code?). So PCON.3 = 1 or if you wish you can create an alias to the bit, like:With that said the default state of the OSCF bit is '1' so it will start up at 4MHz.Code:OSCF VAR PCON.3 OSCF = 1
/Henrik.
Bookmarks