Maker Pro
Maker Pro

Help with 16F84 compared to 16F88

B

Bubba

Jan 1, 1970
0
I am just learning about microcontrollers and I am trying to do a simple
circuit. The book I am using shows the circuit with a 4mhz resonator
crystal but radio shack doesn't carry them. I have several chips and one of
the is the 16F88 with a built in clock. I can't figure out how to set the
clock speed to 4mhz looking at the spec sheets.

Here is the datasheet:

http://www.microchip.com/download/lit/pline/picmicro/families/16f8x/30487b.pdf

Am I wrong to say that If I just leave it alone it will be set to 8mhz by
default and is there a way through the programming to get it to 4mhz??

Thanks!!
 
S

Spehro Pefhany

Jan 1, 1970
0
I am just learning about microcontrollers and I am trying to do a simple
circuit. The book I am using shows the circuit with a 4mhz resonator
crystal but radio shack doesn't carry them. I have several chips and one of
the is the 16F88 with a built in clock. I can't figure out how to set the
clock speed to 4mhz looking at the spec sheets.

Here is the datasheet:

http://www.microchip.com/download/lit/pline/picmicro/families/16f8x/30487b.pdf

Am I wrong to say that If I just leave it alone it will be set to 8mhz by
default and is there a way through the programming to get it to 4mhz??

You should program the configuration bits so that the processor uses
the internal clock, and you have to set OSCCON ICRF 2:0 to 110 as on
page 42 of the PDF. 000 (31kHz) is the POR state. It cannot start up
at 8MHz because Vdd might be too low for reliable operation at such a
high speed (eg. 2.0V)

Best regards,
Spehro Pefhany
 
J

Jeffrey Turner

Jan 1, 1970
0
Bubba said:
I am just learning about microcontrollers and I am trying to do a simple
circuit. The book I am using shows the circuit with a 4mhz resonator
crystal but radio shack doesn't carry them. I have several chips and one of
the is the 16F88 with a built in clock. I can't figure out how to set the
clock speed to 4mhz looking at the spec sheets.

Here is the datasheet:

http://www.microchip.com/download/lit/pline/picmicro/families/16f8x/30487b.pdf

Am I wrong to say that If I just leave it alone it will be set to 8mhz by
default and is there a way through the programming to get it to 4mhz??

To get 4MHz, load 64H (100) into the OSCCON register (addr 8FH)[p.
42]. But that is only for the chip's internal clock (by setting bits
4,1,0 of the CONFIG1 register [addr2007h] to 110 you can get
one-fourth of that frequency out of pin OSC1 [p.37, p. 132]). If you
need to distribute 4MHz to the external circuit you have to use an
external RC configuration on pin OSC1 and set pins 4,1,0 of CONFIG1 to
100. You may have to play with the RC values to get your 4MHz out,
approximate values would be 27 ohms and 0.1 uF [p. 39]. Good luck.

Maybe if you have a link to the schematic I can be more helpful.

--Jeff

--
A man, a plan, a cat, a canal - Panama!

Ho, ho, ho, hee, hee, hee
and a couple of ha, ha, has;
That's how we pass the day away,
in the merry old land of Oz.
 
B

Bubba

Jan 1, 1970
0
Thanks Guys!!

I only need to use the internal clock for the circuit I am building.
Currently it is just a button that turns on a led. Like I said I am very
new to pics so I am going one example ata time. I am using a 1000 page
book on programming microcontrollers. It is pretty good so far but I still
have a lot to learn. Thanks again guys, Joey

Jeffrey Turner said:
Bubba said:
I am just learning about microcontrollers and I am trying to do a simple
circuit. The book I am using shows the circuit with a 4mhz resonator
crystal but radio shack doesn't carry them. I have several chips and one of
the is the 16F88 with a built in clock. I can't figure out how to set the
clock speed to 4mhz looking at the spec sheets.

Here is the datasheet:

http://www.microchip.com/download/lit/pline/picmicro/families/16f8x/30487b.pdf

Am I wrong to say that If I just leave it alone it will be set to 8mhz by
default and is there a way through the programming to get it to 4mhz??

To get 4MHz, load 64H (100) into the OSCCON register (addr 8FH)[p.
42]. But that is only for the chip's internal clock (by setting bits
4,1,0 of the CONFIG1 register [addr2007h] to 110 you can get
one-fourth of that frequency out of pin OSC1 [p.37, p. 132]). If you
need to distribute 4MHz to the external circuit you have to use an
external RC configuration on pin OSC1 and set pins 4,1,0 of CONFIG1 to
100. You may have to play with the RC values to get your 4MHz out,
approximate values would be 27 ohms and 0.1 uF [p. 39]. Good luck.

Maybe if you have a link to the schematic I can be more helpful.

--Jeff

--
A man, a plan, a cat, a canal - Panama!

Ho, ho, ho, hee, hee, hee
and a couple of ha, ha, has;
That's how we pass the day away,
in the merry old land of Oz.
 
B

Byron A Jeff

Jan 1, 1970
0
-Thanks Guys!!
-
-I only need to use the internal clock for the circuit I am building.
-Currently it is just a button that turns on a led. Like I said I am very
-new to pics so I am going one example ata time. I am using a 1000 page
-book on programming microcontrollers. It is pretty good so far but I still
-have a lot to learn. Thanks again guys, Joey

I'd like to share some advise with you for your journey. Be aware that using
a 16F84 book when you're programming a 16F88 or other modern PIC is like
reading a 1967 car repair manual to repair a 2003 car. While most of the
systems are the same at a basic level, the organization is completely
different. In short the 16F84 book will show you how to do things the 16F84
way instead of the modern way.

A couple of quick examples:

1) Your book shows how to generate serial data using a bit banged interface.
the 16F88 (and most of the other recent PICs) has a hardware UART which the
book probably won't cover. The best tutorial on the UART is Fr. Thomas
McGahee's PICUART.ASM which you can find on http://www.pic101.com. The point
is that you need to be aware that there's probably a better way to do it.

2) generating, sampling, and comparing analog signals of all types has to be
done by hand with a 16F84. Say for example you wanted to dim a LED. With the
16F84 you'd have to do PWM by hand. But the 16F88 has PWM built in so that it's
set and forget.

There's a host of other examples (multiple timers, capture/compare) that
also whould have to be done by hand. Having an awareness of the differences
can go a long way in simplifying how you write software for the newer parts.

Your best reference is the Microchip 16F midrange reference manual which you
can download from microchip's web site for free. It has 700 pages of examples,
code, and explanations on each and every peripheral you'll find in the 16F
family, most of which the 16F88 carries.

Hope this helps,

BAJ
 
Top