How to Access the Clock in Program

Discussion in 'Embedded Systems and Microcontrollers' started by Allen_Lusy, Mar 30, 2015.

  1. Allen_Lusy

    Thread Starter New Member

    Dec 10, 2014
    10
    0
    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.
     
  2. R!f@@

    AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    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
     
  3. Allen_Lusy

    Thread Starter New Member

    Dec 10, 2014
    10
    0
    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.
     
  4. R!f@@

    AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    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.
     
  5. Allen_Lusy

    Thread Starter New Member

    Dec 10, 2014
    10
    0
    I am getting bit confused by searching it google. So i request experts like you to suggest me to study correct material.
     
  6. R!f@@

    AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    What is your programming language and uC preference. ?
     
  7. Allen_Lusy

    Thread Starter New Member

    Dec 10, 2014
    10
    0
    My programming language is C. And I am using STM32(ARm Core)
     
  8. R!f@@

    AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    Sorry not my area of language.
    You have to wait for others to see the thread.
     
  9. josip

    Member

    Mar 6, 2014
    63
    12
    It can be also over XTAL, depending on microcontroler.
     
  10. MrChips

    Moderator

    Oct 2, 2009
    12,442
    3,361
    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).
    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.
    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.
    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.
     
  11. M.S.ARUL

    New Member

    Mar 4, 2015
    1
    0
    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..?
     
  12. RRITESH KAKKAR

    Senior Member

    Jun 29, 2010
    2,831
    89
    Hello,
    Yes freq depend on PLL in latest heavy micro, in middle range crystal is used.
    anyway what are you making?
     
Loading...