Oscillator frequency setting

General discussion on mikroBasic PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
gbtjom
Posts: 58
Joined: 13 Jan 2012 23:48

Oscillator frequency setting

#1 Post by gbtjom » 11 Nov 2012 20:29

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

arco
Posts: 312
Joined: 15 Apr 2008 13:54
Location: The Netherlands

Re: Oscillator frequency setting

#2 Post by arco » 11 Nov 2012 23:48

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)
Regards,

Peter.

programmer5
Posts: 69
Joined: 28 Jan 2012 06:50
Location: Pakistan
Contact:

Re: Oscillator frequency setting

#3 Post by programmer5 » 12 Nov 2012 08:02

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

gbtjom
Posts: 58
Joined: 13 Jan 2012 23:48

Re: Oscillator frequency setting

#4 Post by gbtjom » 12 Nov 2012 18:04

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

programmer5
Posts: 69
Joined: 28 Jan 2012 06:50
Location: Pakistan
Contact:

Re: Oscillator frequency setting

#5 Post by programmer5 » 12 Nov 2012 18:30

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

Post Reply

Return to “mikroBasic PRO for dsPIC30/33 and PIC24 General”