Hi,
I am looking to add 10 ms delay in the code. I am not sure if there is any delay function in chibios. But I can add a delay function if I knew the clock frequency. I tried to find out what clock frequency my code has but didn't get anywhere.
Does anyone know how to find clock frequency in mycode or add delay?
Thank you.
How do I get system clock frequency?
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: How do I get system clock frequency?
It is in any demo...
chThdSleepMilliseconds()
...or in the documentation...
http://chibios.sourceforge.net/html/gro ... e4cad9f56f
...or you may also look at this article...
http://www.chibios.org/dokuwiki/doku.ph ... :kb:timing
Giovanni
chThdSleepMilliseconds()
...or in the documentation...
http://chibios.sourceforge.net/html/gro ... e4cad9f56f
...or you may also look at this article...
http://www.chibios.org/dokuwiki/doku.ph ... :kb:timing
Giovanni
-
Faisal Mehmood
- Posts: 25
- Joined: Sat Jan 26, 2013 10:18 pm
Re: How do I get system clock frequency?
I guess you would have figured it out already. In case you didn't:
When the kernel has been initialized, the main() function becomes a thread as well. It is documented in the demo:
ChThdSleepMilliseconds() will 'sleep' the main 'thread' for the specified milliseconds.
When the kernel has been initialized, the main() function becomes a thread as well. It is documented in the demo:
Code: Select all
/*
* Application entry point.
*/
int main(void) {
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
chSysInit();
(remaining demo follows...)
ChThdSleepMilliseconds() will 'sleep' the main 'thread' for the specified milliseconds.
-
Guillaume227
- Posts: 15
- Joined: Tue Apr 18, 2017 6:52 pm
- Has thanked: 10 times
Re: How do I get system clock frequency?
Going back to the title question (the op was actually interested in adding delay to his code so the discussion stopped there) :
I do not see anywhere in the API a method that returns the clock frequency which the MCU is set to.
What's the recommended way to access that value?
I do not see anywhere in the API a method that returns the clock frequency which the MCU is set to.
What's the recommended way to access that value?
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: How do I get system clock frequency?
Hi,
For STM32 it is STM32_HCLK, it is HAL exporting it.
Giovanni
For STM32 it is STM32_HCLK, it is HAL exporting it.
Giovanni
-
electronic_eel
- Posts: 95
- Joined: Sat Mar 19, 2016 8:07 pm
- Has thanked: 8 times
- Been thanked: 23 times
Re: How do I get system clock frequency?
Wouldn't it make sense to provide the frequency in a hardware-independent way?
Or is there some limitation that makes it hardware dependant?
Or is there some limitation that makes it hardware dependant?