1. 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.
    Dismiss Notice

Making PICs go faster

Discussion in 'Microcontrollers' started by BobW, Mar 1, 2017.

  1. BobW

    BobW Active Member

    Joined:
    Apr 28, 2010
    Messages:
    443
    Likes:
    45
    Location:
    Canada
    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.

    http://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?
     
  2. Les Jones

    Les Jones Well-Known Member

    Joined:
    May 15, 2015
    Messages:
    1,377
    Likes:
    176
    Location:
    Lancashire UK
    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.
     
    • Like Like x 1
  3. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    8,664
    Likes:
    826
    Location:
    Rochdale UK
    ONLINE
    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...
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Les Jones

    Les Jones Well-Known Member

    Joined:
    May 15, 2015
    Messages:
    1,377
    Likes:
    176
    Location:
    Lancashire UK

    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.
     
  6. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    8,664
    Likes:
    826
    Location:
    Rochdale UK
    ONLINE
    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!!!!
     
  7. NorthGuy

    NorthGuy Well-Known Member

    Joined:
    Sep 8, 2013
    Messages:
    1,218
    Likes:
    206
    Location:
    Northern Canada
    ONLINE
    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.
     
    • Thanks Thanks x 1
    • Agree Agree x 1
  8. granddad

    granddad Active Member

    Joined:
    Jan 18, 2015
    Messages:
    686
    Likes:
    63
    Location:
    Worcestershire UK
    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.
     
  9. BobW

    BobW Active Member

    Joined:
    Apr 28, 2010
    Messages:
    443
    Likes:
    45
    Location:
    Canada
    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. :)
     
  10. Jon Wilder

    Jon Wilder Active Member

    Joined:
    Oct 22, 2010
    Messages:
    842
    Likes:
    80
    Location:
    Fresno, CA
    ONLINE
    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.
     
    • Agree Agree x 1
  11. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    38,785
    Likes:
    600
    Location:
    Derbyshire, UK
    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.
     
    • Agree Agree x 1
  12. Jon Wilder

    Jon Wilder Active Member

    Joined:
    Oct 22, 2010
    Messages:
    842
    Likes:
    80
    Location:
    Fresno, CA
    ONLINE
    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: Mar 15, 2017
  13. BobW

    BobW Active Member

    Joined:
    Apr 28, 2010
    Messages:
    443
    Likes:
    45
    Location:
    Canada
    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.
     
  14. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    38,785
    Likes:
    600
    Location:
    Derbyshire, UK
    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?.
     
  15. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    9,716
    Likes:
    279
    Location:
    Brisbane Australia
    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
     
    • Agree Agree x 2
  16. granddad

    granddad Active Member

    Joined:
    Jan 18, 2015
    Messages:
    686
    Likes:
    63
    Location:
    Worcestershire UK
    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 ..
     
    • Like Like x 1
  17. Mike - K8LH

    Mike - K8LH Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    3,572
    Likes:
    89
    Location:
    Michigan, USA
    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
     
    • Like Like x 1
  18. NorthGuy

    NorthGuy Well-Known Member

    Joined:
    Sep 8, 2013
    Messages:
    1,218
    Likes:
    206
    Location:
    Northern Canada
    ONLINE
    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.
     
  19. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    8,664
    Likes:
    826
    Location:
    Rochdale UK
    ONLINE
    Please tell that to several Indian gentlemen who do not seem to be able to buy micro's without a wind up handle...
     
  20. Jon Wilder

    Jon Wilder Active Member

    Joined:
    Oct 22, 2010
    Messages:
    842
    Likes:
    80
    Location:
    Fresno, CA
    ONLINE
    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.
     
  21. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    38,785
    Likes:
    600
    Location:
    Derbyshire, UK
    The 628's internal oscillator was no where as good as the more modern devices.
     

Share This Page