How to Access the Clock in Program

Thread Starter

Allen_Lusy

Joined Dec 10, 2014
12
Hi,
I started to do a coding for Microcontroller, I have some following doubts,

1) Every Microcontroller has Clock(Which will vary controller by controller). Take it for example,
I am using a Controller which is having 32MhZ. This frequency can be changed for 16MhZ also. But how can i change this.
Is there any Hardware register to achieve this.
2) If my process is multi threading, is it possible to set a different frequency for two running thread.

3) Running RTC
i) I have seen that, RTC will run only on External Crystal. Why it will not run internal(Controller Clock)?
ii) I read some where, if want to take a reference of External Clock, Need to access from a GPIO. Is this Correct,
If Yes, how can i reference through GPIO. If No, then what should i do in program to access External Crystal.
 

R!f@@

Joined Apr 2, 2009
10,004
1) Every Microcontroller has Clock(Which will vary controller by controller). Take it for example,
I am using a Controller which is having 32MhZ. This frequency can be changed for 16MhZ also. But how can i change this.
Is there any Hardware register to achieve this.
You can use internal register to assign the clock frequency you want it to run but it will be lower than the xtal you are using

2) If my process is multi threading, is it possible to set a different frequency for two running thread.
Yes

3) Running RTC
i) I have seen that, RTC will run only on External Crystal. Why it will not run internal(Controller Clock)?
It will, if you code it properly ( do not need RTC for this though)
ii) I read some where, if want to take a reference of External Clock, Need to access from a GPIO. Is this Correct,
If Yes, how can i reference through GPIO. If No, then what should i do in program to access External Crystal.
External Xtal assigning should be done in config. Word depends on the uPC
 

Thread Starter

Allen_Lusy

Joined Dec 10, 2014
12
You can use internal register to assign the clock frequency you want it to run but it will be lower than the xtal you are using


Yes


It will, if you code it properly ( do not need RTC for this though)

External Xtal assigning should be done in config. Word depends on the uPC
Thanks for your response,
Since i am newbie, I want to strong in basics. I can code well, the only weakness of me is only accessing the Clock. How it really works. What is the use of external clock, how to use it. If i use external Clock, whether, it will change whole code timing process(I mean will effect to internal Clock). So can you suggest or give a any link, where i can make a complete study of this.
 

R!f@@

Joined Apr 2, 2009
10,004
I wonder how you code well if you have no idea how to use the external or internal clock ?

Try Googling you will find plenty of info.
 

Thread Starter

Allen_Lusy

Joined Dec 10, 2014
12
I wonder how you code well if you have no idea how to use the external or internal clock ?

Try Googling you will find plenty of info.
I am getting bit confused by searching it google. So i request experts like you to suggest me to study correct material.
 

MrChips

Joined Oct 2, 2009
34,812
Hi,
I started to do a coding for Microcontroller, I have some following doubts,

1) Every Microcontroller has Clock(Which will vary controller by controller). Take it for example,
I am using a Controller which is having 32MhZ. This frequency can be changed for 16MhZ also. But how can i change this.
Is there any Hardware register to achieve this.
You have to tell us the full part number of the MCU for us to be able to help you.
Download the Reference Manual for that MCU from st.com and read the chapter on RCC (Reset and Clock Control).
2) If my process is multi threading, is it possible to set a different frequency for two running thread.
You can use an internal timer for different threads. Why do you want to change the clock frequency?
You would keep the clock frequency constant but use an internal timer for whatever timing function you require.
3) Running RTC
i) I have seen that, RTC will run only on External Crystal. Why it will not run internal(Controller Clock)?
The RTC is designed to be used with a standard 32768Hz quartz crystal. You can also use the HSE_RTC (High Speed External) or LSI (Low Speed Internal) clocks.
ii) I read some where, if want to take a reference of External Clock, Need to access from a GPIO. Is this Correct,
If Yes, how can i reference through GPIO. If No, then what should i do in program to access External Crystal.
What do you mean by reference?
What frequency signal do you wish to generate?

There are many ways to generate a clock signal.
You can use an internal timer module.
You can use MCO1 and MCO2 (Microcontroller Clock Output).

The beauty of the STM32 architecture is that it provides a number of ways to access the hardware.
 

M.S.ARUL

Joined Mar 4, 2015
1
3) Running RTC
i) I have seen that, RTC will run only on External Crystal. Why it will not run internal(Controller Clock)?
ii) I read some where, if want to take a reference of External Clock, Need to access from a GPIO. Is this Correct,
If Yes, how can i reference through GPIO. If No, then what should i do in program to access External Crystal.
I have one doubt on this, If RTC run on internal(Controller) clock, then what is the use of it, Controller can calculate the timing`s. Is RTC provide any other advantage on this..?
 
Top