Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC internal oscillator precision

Status
Not open for further replies.

Dan East

New Member
I have a PIC16F84A that I'm working with. After much rewriting of the ASM, I've determined that the PIC is running around 20% too fast. My bit length for 9600 baud serial communication should be 104 cycles, but I have to use 125 cycles per bit for the data to be properly interpreted (tested with several receiving devices).

Is a deviation of 20% normal for a PIC16F84A? Is the thought of using the internal oscillator for serial communications completely laughable?

Thanks!

Dan East
 
The 16F84A doesn't have an internal oscillator, what are you using?.

I've happily used the internal oscillator of a 16F628 for RS232 at 9600 baud on many occasions, you can check the code in my tutorials. The code will work on a 16F84A with very few changes.
 
PIC16F84A-04/P is the label on the chip. When I program it (using IC Prog) I specify RC for the oscillator. I'm using an 8 pin to 18 pin adapter with the PIC, as I am designing for the PIC12C508A. This adapter board only has 2 caps and a resistor in it - no crystal.

Dan East
 
RC oscillator is an external resistor/capacitor oscillator wich is probably what is installed on the adaptor board. It is normal for a external RC to be unprecise. Even when using precision R and C it will still be 'off'...

The internal oscillators in some pics (like the 12c508) is more precise because it has a calibration byte to fine tune the oscillator...

If you want more precision on your 'F84, use a crystal
 
Dan East said:
PIC16F84A-04/P is the label on the chip. When I program it (using IC Prog) I specify RC for the oscillator. I'm using an 8 pin to 18 pin adapter with the PIC, as I am designing for the PIC12C508A. This adapter board only has 2 caps and a resistor in it - no crystal.
/quote]

As you are using an external RC oscillator you can simply alter the values so it runs at the correct speed - or simply move to the 16F628 which has an internal oscillator, and is the modern replacement for the 16F84A.
 
Hmm. The PCB is marked 22pF and 100mF. However I see the one cap is 104mF. So perhaps the 4mF is enough to cause the 20% overclocking? The resistor is 4700 ohm. Regardless, I would think using capacitors to oscillate something this time-critical is a bad way to go.

I was designing for the PIC12C508A (which is why I'm using an 8 to 18 pin adapter, so I could develop with the rewritable PIC16F84A), but I have since discovered that it's an older chip. So I am going to use the PIC12F629 instead, assuming my el-cheapo programmer can handle it. Since it has flash memory and an internal oscillator the whole 8 to 18 pin adapter will be a moot point.

Thanks for the info guys!

Dan East
 
Dan East said:
Hmm. The PCB is marked 22pF and 100mF. However I see the one cap is 104mF. So perhaps the 4mF is enough to cause the 20% overclocking?

It's a bit confusing using the prefix 'm' (for milli) rather than the prefix 'u' (for micro), but presumably you meant 100uF?. There's no such cap as a 104uF (or 104mF) - if the capacitor is marked 104 it means 100,000pF, or 0.1uF. In any case, if it's supposed to be 100uF it's just an HT decoupler, and won't affect the timing.

As you suggested, you are probably better off using one of the new FLASH 8 pin PIN's with an internal oscillator.
 
:idea:

Buy youself a couple of 12F675 chips these are pin for pin compatible with the 508, and have an internal OSC, I am running 1 here today which is doing r232 on 2 pins (one with a 10k to the PC 9way, the other straight to the PC 9way).

The calibration on the 12F675 is a little bit weird (compared to the 508) you need to load the calibration as below.....

MOVLW H'07' ;VALUE TO TURN OFF COMPARATORS
MOVWF CMCON ;TURN OFF COMPARATORS

;****** START OF BANK 1 REG INIT'S

CALL H'03FF' ;GET OSC CALLIBRATION

BSF STATUS,RP0 ;SWITCH TO BANK1

MOVWF OSCCAL ;SETUP OSC CAILIBRATION

BCF STATUS,RP0 ;SWITCH TO BANK0

I hope this helps!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top