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.

Making PICs go faster

Status
Not open for further replies.

BobW

Active Member
For most things I do with PICs, the internal 4MHz oscillator is just fine, and saves an I/O pin or two. But I have a few 20MHz oscillators on hand for those times when I need things to go faster. The oscillators that I have are CTS MXO45HST series.

https://www.ctscorp.com/wp-content/uploads/2015/11/008-0258-0.pdf

I've never needed to use one until now. Looking at the datasheet, I'm wondering if these are overkill. They can drive 10 TTL loads which might be nice for some applications, but completely unnecessary for driving the clock input on a PIC. One of the things that I like about PICs is that they are extremely low power, and generate negligible EMI. Having this big honking oscillator seems to be generating a lot of noise on the power supply lines. Can anyone suggest some 20MHz oscillators that are very low power?
 
Hi Bob,
You could just use a 20 Mhz crystal such as this one. The only disadvantage over an external oscillator is that you lose one extra I/O pin. If you change to one of the more modern PICs some have an internal 32 Mhz 0scillator.

Les.
 
Most new pic's have a really low power 4Mhz internal OSC that can be ramped to 32Mhz with the internal PLL.

No need for a crystal at all..

I use the pic16f1825 very regularly... With speeds from 32kHz up to 32Mhz, I normally run these at 1Mhz, but the option is there.... Virtually all the new Pic's are the same..

EDIT sorry Les.. Didn't read you post fully...
 
Hi Ian,
One thing that I should have warned Bob about was that some of the newer PICs can't be programmed with PICKIT2. They need a PICKIT3.
Yesterday I thought I would try the automatic OSCCAL feature on a PICKIT2 after seeing a comment about it on a forum. (Using a PIC12F629) I first tried it on my i5/760 running 64 bit Windows 7. It reported that it had worked but had not changed the last location in program memory. I also tried other methods. I tried the manual setting for OSCCAL and that did not work. I tried edditing the last program memory location in the PICKIT2 memory display. I also tried loading a program that had a RETLW 0x7F instruction in the last location. I then tried it on an old AMD64 running 32 bit XP and the OSCCAL function worked without a problem. (I was using V2.61 of the PICKIT2 software on both systems.

Les.
 
I would imagine you need to run the program as windows XP service pack 2 or just try running the program as administrator... God only knows where the buffer for the write is.. It would more likely be the initial run directory of the pickit2 software that's causing the issue... This is windows user protection system gone haywire... I always think, if you log on YOUR OWN computer, you will be an administrator.. SO WHY DOES IT ALWAYS LOCK YOU OUT!!!!
 
Newer PIC16s run at 32MHz with Internal oscillator, some even at 48MHz. PIC18s such as recent PIC18F2xK40 run at 64MHz. These are also much cheaper than the old obsolete ones. PIC24/dsPIC33 are yet faster, and more powerful. Choosing the correct PIC will take you much further than mingling with the old ones.
 
Bear in mind osc frequency is not MIPS , PIC 16,18 are / 4 , but 16 bit PIC24/dsPIC33 are / 2 so 70 MIPS is achievable.
 
Thanks for the replies. I guess it's time for me to modernize to the newer PIC series. I'll save my supply of older PICs for slow things.
Programming won't be a problem. I have a PICkit3.
As for the current project, I'll see if I can free up another pin and replace the oscillator with a crystal. Things are a bit tight since I'm using a 14 pin 16F630 that's talking to an AD9851 DDS, a 2 line LCD display, a D/A converter, a numeric keypad and a 4 position rotary switch. :)
 
Regardless of the availability of internal oscillators, I'm still a huge advocate of external crystal oscillators. The internal oscillator calibration is temperature dependent. You don't have this issue with an external crystal. The timing on them is VERY tight, they're cheap, and I've never had a single timing related issue with external crystals.
 
Regardless of the availability of internal oscillators, I'm still a huge advocate of external crystal oscillators.

Which is fine for the odd occasion it's needed, for the VAST majority of cases it's not - thus freeing up the maximum number of I/O pins, and reducing component count.

I can't even remember the last time I had occasion to use a crystal oscillator - other than 32KHz ones for clock timing purposes.
 
Since most of what I do uses asynchronous serial communications I ensure I have a crystal oscillator available. I've attempted to use the internal oscillator for this and have ended up with frame errors while doing so. This was at 31.25Kbps bit rate, <TXSTA:BRGH> = 1, SPBRG = 31, BAUDCON:BRG16 = 0. SPBRG value of 31 was derived from -

((Fosc / Baud) / 16) - 1 where:

Fosc = 16MHz
Baud = 31.25Kbps
 
Last edited:
I ended up ordering a bunch of 20 MHz ceramic resonators from Digikey. At $0.24 each they're a lot cheaper than crystals and oscillators. I don't need the accuracy of a crystal for this application, and I was able to double up two I/O functions and free up the pins for the resonator. The result is much better. The glitches that the separate crystal oscillator was putting out are gone.
The only time I've needed crystal accuracy is for a couple of frequency counter projects. I've done a serial interface project using a 16F628A using the internal oscillator and had no framing error problems. However, I avoided baud rates where the divide rate was borderline.
 
Since most of what I do uses asynchronous serial communications I ensure I have a crystal oscillator available. I've attempted to use the internal oscillator for this and have ended up with frame errors while doing so. This was at 31.25Kbps bit rate, <TXSTA:BRGH> = 1, SPBRG = 31, BAUDCON:BRG16 = 0. SPBRG value of 31 was derived from -

((Fosc / Baud) / 16) - 1 where:

Fosc = 16MHz
Baud = 31.25Kbps

Sounds like you're doing something wrong somewhere?, there should be no problems using any correctly setup modern PIC for serial comms. I've done 115KBaud with no problems on the 16F1827, and more recently on the 24F series.

What specific PIC were you using?.
 
I've never had a problem using rs232 with the internal oscillator. In fact, I think the last time I used a crystal was about 10 years ago!

Mike
 
Internal osc and PPL can be a bit challenging , But with PIC24 I used the clock out pin with a 16F628 * frequency counter to decipher the PPL magic... ! 140Mhz no problem ...
* Thanks to ETO ..
 
You really should not have had a problem using INTOSC with that Fosc and baud rate (0% bit rate error ±1% INTOSC)...

spbrg midi.png
 
Since most of what I do uses asynchronous serial communications I ensure I have a crystal oscillator available. I've attempted to use the internal oscillator for this and have ended up with frame errors while doing so. This was at 31.25Kbps bit rate, <TXSTA:BRGH> = 1, SPBRG = 31, BAUDCON:BRG16 = 0. SPBRG value of 31 was derived from -

((Fosc / Baud) / 16) - 1 where:

Fosc = 16MHz
Baud = 31.25Kbps

Different PICs have different internal oscillators. They all have different tolerances. New PICs tend to have better internal oscillators, which are good enough for UART (often much better than this). There's no reason to use old PICs.
 
This was with a PIC16F628A. I needed the I/O, hence I attempted to use the internal oscillator. Once I encountered those issues, I redesigned it around the 16F886. Since I now had more I/O than I needed, and remembering the aforementioned issues I had using the internal OSC, I designed in an external crystal.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top