Connect with us

RC OSCILLATOR in pic16f877

Discussion in 'Microcontrollers, Programming and IoT' started by ami85t, Mar 11, 2014.

Scroll to continue with content
  1. ami85t

    ami85t

    71
    0
    Feb 19, 2014
    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
     

    Attached Files:

  2. Harald Kapp

    Harald Kapp Moderator Moderator

    9,543
    1,969
    Nov 17, 2011
    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.
     
  3. ami85t

    ami85t

    71
    0
    Feb 19, 2014
    Thanks!
     
  4. kpatz

    kpatz

    247
    52
    Feb 24, 2014
    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.
     
  5. ami85t

    ami85t

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

    jpanhalt

    426
    4
    Nov 12, 2013
    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
     
  7. ami85t

    ami85t

    71
    0
    Feb 19, 2014
    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: Mar 12, 2014
  8. ami85t

    ami85t

    71
    0
    Feb 19, 2014
    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
     
  9. Anish

    Anish

    46
    0
    Feb 5, 2011
    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
     
  10. ami85t

    ami85t

    71
    0
    Feb 19, 2014
    Thanks!
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-