Difference between MCU clock and oscillator
Difference between MCU clock and oscillator
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.
- jovana.medakovic
- mikroElektronika team
- Posts: 986
- Joined: 18 Dec 2018 10:36
Re: Difference between MCU clock and oscillator
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
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
Re: Difference between MCU clock and oscillator
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.
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!
Learning is an endeless process but it must start somewhere!