Maker Pro
Maker Pro

RC OSCILLATOR in pic16f877

ami85t

Feb 19, 2014
71
Joined
Feb 19, 2014
Messages
71
Hi,

In the pic16f877 data sheet is written:
"The RC oscillator
frequency is a function of the supply voltage, the resistor
(REXT) and capacitor (CEXT) values, and the operating
temperature. In addition to this, the oscillator
frequency will vary from unit to unit due to normal process
parameter variation."

The frequency value is derived from a capacitor and resistor values.
Q1. Is there any way that I can now approximately what will this frequency
be? I want to write a code in advance before I get the pic and
I want to know which value to enter into the SPBRG register so to
determine the baud rate. ( Baud Rate = FOSC/(4(SPBRG+1) )
Q2. will the output frequency be fosc/4 as seen in the diagram?

Thanks, Amitai
 

Attachments

  • Capture.PNG
    Capture.PNG
    42.9 KB · Views: 165

Harald Kapp

Moderator
Moderator
Nov 17, 2011
12,607
Joined
Nov 17, 2011
Messages
12,607
A1) Unfortunately I cannot find any reference in the datasheet as to which component values give which frequency.

A2) Yes, that's what the datasheet states.

If yu're going o use the UART, I recommend you do not use the RC oscillator but a crystal. A 32kHz xrystal is small, inexpensive and a lot more stable than an RC oscillator. The timing variations from the RC oscillator will make UART transmission rather unreliable.
 

kpatz

Feb 24, 2014
329
Joined
Feb 24, 2014
Messages
329
Actually, you should use a higher frequency crystal. 32 KHz would make for a really slow processor that couldn't handle more than a few hundred baud. Use something like a 4 MHz crystal, or an 8 MHz if you need some more speed.

If you need accurate RS232 standard baud rates like 9600, 19200, 57600 etc. you can use a crystal that divides down to these values, such as 3.6864 or 7.3728 MHz.

You'll need 2 load capacitors, connected between each pin of the crystal and ground. 20 pF is typical. Then set the configuration word of the CPU to use the crystal (XT or HS mode) instead of the RC oscillator.
 

ami85t

Feb 19, 2014
71
Joined
Feb 19, 2014
Messages
71
Actually I read exactly the same thing elsewhere,
and it's nice to see the that I get the same advice..
Thanks again,
Amitai
 

jpanhalt

Nov 12, 2013
426
Joined
Nov 12, 2013
Messages
426
If you check Tables 10-3 and 10-4 in the datasheet, they will show you the appropriate settings for different frequencies. While a resonator of 3.6864 or 7.3728MHz will give the lowest error, a 4-MHz resonator or crystal only gives an error of 0.16% at 9600 baud. That small error will not be a problem.

John
 

ami85t

Feb 19, 2014
71
Joined
Feb 19, 2014
Messages
71
Thanks!
I want to communicate between the pic and a LDC1OOO of TI which communicates via SPI,
and I want to be sure that I understand correctly a few things:
1. does the CSB pin of the LDC need configuration or that it automatically changes when communication is happening?
2. for knowing that a transmission from the LDC to the PIC has finished is the BF check enough or I need to check somehow in the LDC's end for ending of transmission?

Amitai
 
Last edited:

ami85t

Feb 19, 2014
71
Joined
Feb 19, 2014
Messages
71
motion sensoring

Hi,
I have bought a MMA7455 3-Axis Accelerometer Module and I want to use it for a simple purpose
which is getting an indication that a movement of an object ( in which the Accelerometer is) has occurred upwards or downwards.
The Accelerometer needs to send the information to a PIC16f877. The thing is that the PIC is also
connected to another component which communicates only via SPI protocol.
can i communicate with both the components one after another? (twice SPI or SPI and I2C?)
what are the things that need to be done for enabling that?

Thanks, Amitai
 

Anish

Feb 5, 2011
46
Joined
Feb 5, 2011
Messages
46
Hi,
You can connect the two via SPI if they both have SPI. Your controller can act as a master and the two modules as slave. You will have a extra line called slave select line which selects which slave you want to communicate. In the modules using SPI, this pin is generally designated as CS (chip select) or SS (slave select)

Regards
 
Top