PIC16F690 w/ External Clock

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
dslocum
Posts: 102
Joined: 31 Aug 2009 12:21

PIC16F690 w/ External Clock

#1 Post by dslocum » 02 Nov 2020 01:32

Hi folks,

This is the first time I'm trying to use an external clock oscillator. My goal is to have the PIC16F690 run as fast as possible and use the UART for MIDI receive (31250 baud). I'm afraid that the internal RC oscillator will not be accurate or stable enough, so I'm using an external 20MHz package. By setting the Project to "EC" and set the MPU frequency to 20MHz, my project runs, but all Delay functions are running slow. EG. A Delay_ms(100) in code gives me a delay of 500ms.

Maybe I'm missing something. Based on the PIC data sheet "CLOCK SOURCE BLOCK DIAGRAM", I thought by setting the that System Clock should be derived from my external 20MHz oscillator, but all my delays seem to be running at 4MHz. Interestingly, I can force OSCCON IRCF bits to "111" and get twice the speed, but according to the data sheet diagram, that should have no affect.

Not sure what to do. Help from anyone would be appreciated.

Thanks

hexreader
Posts: 1786
Joined: 27 Jun 2010 12:07
Location: England

Re: PIC16F690 w/ External Clock

#2 Post by hexreader » 02 Nov 2020 02:42

Are you using 2-pin 20MHz crystal, or a 4-pin oscillator module?

Attached is my project for 20 MHz 2-pin crystal - timing is good. (checked with half second on, half second off blinking of LEDs on PORTC)

I wonder if you have fail-safe clock and switchover enabled, and maybe external oscillation fails over to internal oscillator that defaults to 4MHz?
Attachments
MIDI.zip
(10.17 KiB) Downloaded 61 times
Last edited by hexreader on 02 Nov 2020 03:12, edited 2 times in total.
Start every day with a smile...... (get it over with) :)

hexreader
Posts: 1786
Joined: 27 Jun 2010 12:07
Location: England

Re: PIC16F690 w/ External Clock

#3 Post by hexreader » 02 Nov 2020 03:07

And here is my MIDI test...

Use an oscilloscope or frequency counter to Measure 15.625 kHz square wave on pin RB7 (UART Tx).
Attachments
MIDI.zip
(13.2 KiB) Downloaded 61 times
Start every day with a smile...... (get it over with) :)

john p
Posts: 40
Joined: 19 Sep 2016 18:54

Re: PIC16F690 w/ External Clock

#4 Post by john p » 08 Nov 2020 19:35

The PIC16F690 was my favorite processor for several years, but I've switched to the PIC16F18345. It has the same pinout, and basically the same features (there are other chips in the enhanced mid-range category which add some and drop some) but with some additions. What's most important for me is that it can self-program, so I just install a bootloader and plug in a serial cable, and it's all I need. What would help with your project is that it's faster (up to 32MHz oscillator, with a phase-lock loop accelerator) and it's no problem that it's cheaper!

Post Reply

Return to “mikroC PRO for PIC General”