Difference between MCU clock and oscillator

mikroC, mikroBasic and mikroPascal PRO for Microchip’s 8-bit PIC MCUs.
Post Reply
Author
Message
GunkutA
Posts: 44
Joined: 16 Jan 2019 11:56

Difference between MCU clock and oscillator

#1 Post by GunkutA » 04 Apr 2019 11:48

Hello I wonder the difference between internal oscillator we set by coding and the MCU clock in edit project window. What is the frequency of PIC? What is the difference and if I set them differently which one will be the frequency of the PIC? Thanks beforehand.

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: Difference between MCU clock and oscillator

#2 Post by jovana.medakovic » 05 Apr 2019 10:31

Hello,

PIC frequency will be the one that you set in the configuration bits and your code.
The frequency which you are supposed to enter in the compiler is used only for the compiler's sake, so it would perform certain calculations properly (i.e. UART baud rate, delays etc...)
If you enter a different frequency in here it won't change the frequency PIC is operating on, but it will result in bad calculation and the above functions won't work properly.

Kind regards,
Jovana

Toley
Posts: 922
Joined: 03 Sep 2008 16:17

Re: Difference between MCU clock and oscillator

#3 Post by Toley » 07 Apr 2019 12:19

Hi GunkutA,

To make a short story, PIC micro execute 1 instruction every 4 oscillator clock. This is called Tcy in the documentation. So if your clock is running at 32MHz you set that frequency in the edit project box but your PIC will run in term of instruction execution at 8MHz. For PIC24/33 the rate is 1:2 and for PIC32 it's 1:1.
Serge T.
Learning is an endeless process but it must start somewhere!

Post Reply

Return to “PIC PRO Compilers”