Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

So how accurate is the internal PIC oscillator? INTOSC

Status
Not open for further replies.

techristian

Member level 1
Member level 1
Joined
Apr 3, 2013
Messages
41
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Windsor, Ontario
musicinit.com
Activity points
1,612
Before I get all wrapped up with the crystals and pf caps I'm going to see if I can get the pic to count up to 3600 (0E10h) seconds (1 hour) consistently and accurately .

If it is anywhere within a few seconds deviation (over a whole hour), I think that I may be able to do serial communications without the need of a crystal.

Dan
 

So how accurate is the internal PIC oscillator?
The datasheet of the PIC will tell you. Different PICs have differing accuracy, typically a percent or two at room temperature.

You can do serial communications (I assume that you mean asynchronous serial) with internal oscillator, for low baud rates at least and if you are in an environment with only small temperature variations.

There are techniques for fine-tuning on the fly, for adjusting according to temperature, for compensating for variations between PICs and different supply voltages.

You may end up with communications that work most of the time for normal use with most end devices.

Or you could make life easy for yourself and use a Crystal as your timing standard. Will cost you a few cents and two I/O pins. But you gain an easy life and a reliable communication link.

My advice is to use that crystal.
 

My advice is to use that crystal.

The program below uses a 3 digit display and runs continuously in a loop counting from 000 to FFF. It takes 1 hour to count to DFD . IT USES NO EXTERNAL CRYSTAL ,only the internal crystal. . Twice in a row it counted exactly to DFD (3581) The target was 3600 for 3600 seconds or 1 hour. I could add NOPS to fine tune it or use the fine tuning function, but there is no need for that. I only need to try this on a few more devices to see if they all come up with DFD after 1 hour. That will prove that the INTOSC is accurate enough to most things. The only thing left to do is code for the MIDI UART 31,250 baud rate and start to input from PORTB.

Code:
#include <p16f1784.inc>

    ;CONFIG1
    ; __config 0x3FE4
      __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON
    ; CONFIG2
    ; __config 0x3FFF
      __CONFIG _CONFIG2, _WRT_OFF & _VCAPEN_OFF & _PLLEN_ON & _STVREN_ON & _BORV_LO & _LPBOR_OFF & _LVP_ON

delay    equ    0x7e
BIGdelay equ 0x7f
NUMBER equ 0x7c ; if over 80h or greater next bank
temp equ 0x7d
NUMBERhi equ 0x7b




    org    0x0000
    goto    start

    org    0x004
    goto    dummyINT

start
        ;3600= 0E10H


    movlw     b'00000000'        ;MOVE ZERO TO ACC "W"orking register
    movwf   NUMBER
    movwf   NUMBERhi
    movwf temp

banksel TRISA; make all outputs
movwf TRISA
movwf TRISC
movwf TRISD

   

    BANKSEL 0
goto firstZERO ;display MSB zero at beginning

loop INCF NUMBER,1
    BZ HIdisplay

aftrHI    movf NUMBER,0
    movwf temp                     ;copy number to temp here
    movlw b'00001111' ;least signifigant digit mask
    andwf temp,0

    CALL hexTable
    movwf    PORTD ;DISPLAY LOW DIGIT
    movf NUMBER,0
    movwf temp
    movlw b'11110000' ;high bit mask
    andwf temp, 1
    LSRF temp, 1
    LSRF temp, 1
    LSRF temp, 1
    LSRF temp, 0 ;shift right 3 times store in W

    CALL hexTable

    movwf    PORTC




    call PAUSE
;loop forever
    goto    loop

    hexTable BRW
    RETLW   b'01110111' ;0
    RETLW   b'01000001' ;1
    RETLW    b'00111011' ;2
    RETLW    b'01101011' ;3
    RETLW    b'01001101' ;4
    RETLW    b'01101110' ;5
    RETLW    b'01111110' ;6
    RETLW    b'01000011' ;7
    RETLW    b'01111111' ;8
    RETLW    b'01001111' ;9
    RETLW    b'01011111' ;A
    RETLW    b'01111100' ;B
    RETLW    b'00110110' ;C
    RETLW    b'01111001' ;D
    RETLW    b'00111110' ;E
    RETLW    b'00011110' ;F


PAUSE movlw 0xA4

    MOVWF BIGdelay
D250    movlw    0xFE
    movwf    delay
l250    decfsz    delay,f
    goto    l250
DECFSZ BIGdelay,f
GOTO D250
    return

HIdisplay INCF NUMBERhi,1
   firstZERO movf NUMBERhi,0
    movwf temp                     ;copy number to temp here
    movlw b'00001111' ;least signifigant digit mask
    andwf temp,0

CALL hexTable
    movwf    PORTA

goto    aftrHI


dummyINT retfie

    end
 

If you set ._CLKOUTEN_OFF to _CLKOUTEN_ON in cofig setting, You get 1/4 clock rate at clock+out pin. For 4MHz internal clock you get 1MHz out which can be monitored by a fequency counter. You don't have to wait for one hour. As internal oscillator reacts to ambient temperature, it can be observed by slightly heating the mcu.
 

The internal oscillator of the PIC is not very accurate, at room temperatures it is about 1% low which means that a clock will lose about 36 seconds a hour. It is possible to add a calibration offset to correct for this error, but the oscillator will then be very dependent on the temperature and voltage, it will make a very poor clock, but may be just acceptable.
The internal oscillator is not accurate enough for reliable high speed serial communication above 9600 baud.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top