This is probably a bit of a lame question but when creating a new project what is the project setting "MCU Clock" referring to? Is it the crystal frequency (presently I have two crystals going) or is it referring to what you ultimately have at Fosc? If it's the latter then what if you change Fosc during use (dynamically)?
Another words what is setting this value in the project do for you? I imagine it would affect certain library calls like "Delay_ms" or whatever. Anything else?
Thanks
jom
Oscillator frequency setting
Re: Oscillator frequency setting
MCU clock is just what it says: the MCU (core) clock. So that would be 32MHz with 8MHz crystal and 4x PLL on...
It affects everything that is fixed at compile-time. (like delay_xx loops as you said)
If you do a clock change, you'll have to take that into account. (divide your delaytime by oldoscval/newoscval)
It affects everything that is fixed at compile-time. (like delay_xx loops as you said)
If you do a clock change, you'll have to take that into account. (divide your delaytime by oldoscval/newoscval)
Regards,
Peter.
Peter.
-
- Posts: 69
- Joined: 28 Jan 2012 06:50
- Location: Pakistan
- Contact:
Re: Oscillator frequency setting
hi!
i played lot with crystal frequency, and i changed oscillator frequency in software many times during single main function and it works on hardware.
now what crystal frequency mentioned in mikroC refers to?
it has no impact on config word, this frequency is used by mikroC compiler libraries, for example if you use this function
delay_ms(500);
and you set frequency in project settings to 8MHz but actually your hardware has 4MHz crystal, then it will give 1sec delay instead of 500ms.
also it is used in other library functions like uart_init(9600) etc, so if you are using one frequency on hardware and have entered some other frequency in project then program will not work properly.
Regards
Farrukh
i played lot with crystal frequency, and i changed oscillator frequency in software many times during single main function and it works on hardware.
now what crystal frequency mentioned in mikroC refers to?
it has no impact on config word, this frequency is used by mikroC compiler libraries, for example if you use this function
delay_ms(500);
and you set frequency in project settings to 8MHz but actually your hardware has 4MHz crystal, then it will give 1sec delay instead of 500ms.
also it is used in other library functions like uart_init(9600) etc, so if you are using one frequency on hardware and have entered some other frequency in project then program will not work properly.
Regards
Farrukh
Re: Oscillator frequency setting
Thanks for the info!
So to be clear the MCU clock is the value usually referred to in the data sheets as Fosc. Correct?
Thanks again!
jom
So to be clear the MCU clock is the value usually referred to in the data sheets as Fosc. Correct?
Thanks again!
jom
-
- Posts: 69
- Joined: 28 Jan 2012 06:50
- Location: Pakistan
- Contact:
Re: Oscillator frequency setting
gbtjom wrote:Thanks for the info!
So to be clear the MCU clock is the value usually referred to in the data sheets as Fosc. Correct?
yes, both are same. and PIC works at Fosc/4.
regards
Farrukh