PDA

View Full Version : 8 MHZ internal configuration



PickyBiker
- 30th April 2010, 16:27
On a PIC16F886, I have tried to use OSCCON to set the internal clock to 8 MHZ by changing OSCCON from 0x60 to 0x70. When I do that everything seems to stop. The default 0x60 works fine, but I would like it be able to use 8 MHz setting.

I am using _WDT_OFF & _INTRC_OSC_NOCLKOUT

I don't see anything else that needs to be set.

What am I missing?

mackrackit
- 30th April 2010, 17:31
Define osc 8
???

PickyBiker
- 30th April 2010, 17:45
With a little more playing around, it seems that if I set _INTOSC instead of _INTRC_OSC_NOCLKOUT, it works. Looking at the datasheet I found a confusing set of clock descriptions: #5 and #6 below describe an EXTERNAL RC osc, while #7 and #8 describe and internal OSCILLATOR. What I don't see is where _INTRC_OSC_NOCLKOUT comes into play because it seems to refer to an INTERNAL RC osc, not the EXTERNAL described in #5 and #6 in the datasheet. Just call me Picky confused Biker.

5. RC – External Resistor-Capacitor (RC) with
FOSC/4 output on OSC2/CLKOUT.
6. RCIO – External Resistor-Capacitor (RC) with I/
O on OSC2/CLKOUT.
7. INTOSC – Internal oscillator with FOSC/4 output
on OSC2 and I/O on OSC1/CLKIN.
8. INTOSCIO – Internal oscillator with I/O on
OSC1/CLKIN and OSC2/CLKOUT.

To add to the confusion, the .inc file shows these to be the same!!!
_INTRC_OSC_NOCLKOUT EQU H'3FFC'
_INTRC_OSC_CLKOUT EQU H'3FFD'
_EXTRC_OSC_NOCLKOUT EQU H'3FFE'
_EXTRC_OSC_CLKOUT EQU H'3FFF'
_INTOSCIO EQU H'3FFC'
_INTOSC EQU H'3FFD'

mackrackit
- 30th April 2010, 17:56
7 and 8 do talk about the internal OSC.
To find all of the available config option, go to Micrchip in your program file and look at the MPASM directory. There you will find another set of *.inc files for each chip. Do not modify these. At the end of each file the config options are listed.

Here is the configs I use for this one.


@ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
OSCCON = %01110000

PickyBiker
- 30th April 2010, 18:16
Yes, I looked at the .inc file and got further confused because the two items in red are both defined as H'3FFC', yet one says there is no clock out, and the other says there is a clock out. This has to be a .inc file problem or, there is something about that that escapes me. The bottom line here is that I can make this work, but I do not understand why it works and why these things are defined the way they are.

_INTRC_OSC_NOCLKOUT EQU H'3FFC'
_INTRC_OSC_CLKOUT EQU H'3FFD'
_EXTRC_OSC_NOCLKOUT EQU H'3FFE'
_EXTRC_OSC_CLKOUT EQU H'3FFF'
_INTOSCIO EQU H'3FFC'
_INTOSC EQU H'3FFD'
_EXTRCIO EQU H'3FFE'
_EXTRC EQU H'3FFF'

mackrackit
- 30th April 2010, 18:19
As far as I know just different ways of writing the same thing.

PickyBiker
- 30th April 2010, 20:30
:) You are correct dave.

I took a break and went out to fly my RC plane. On the way home, I figured out what was tripping me up. It's really simple. _INTOSCIO EQU H'3FFC' is looking at things from the IO point of view. In that case, if the pins are IO, they are not clocks and vice-versa. _INTRC_OSC_NOCLKOUT EQU H'3FFC' is looking at things from the clock point of view so when the pins are not clocks, they are IO's, and vice versa. So, indeed, the two items I highlighted in the previous post are the same.

Taking a break when you are banging your head against the wall is a good thing.