Where to find "SysTick->VAL" is modified ?
Posted: Sat Mar 02, 2024 10:34 am
Hi,
I just want to learn how things are working, I've been searching about source code which is responsible for setting system clock or function that count millis and micros for the micrcontroller.
I found it in this path:
Everything is good, I just want to know where is modified.
I opened all the included libraries, but couldn't find it there.
I just want to learn how things are working, I've been searching about source code which is responsible for setting system clock or function that count millis and micros for the micrcontroller.
I found it in this path:
Which are these two functions:...\Arduino\hardware\Arduino_Core_STM32-main\libraries\SrcWrapper\src\stm32\clock.c
Code: Select all
#include "backup.h"
#include "clock.h"
#include "lock_resource.h"
#include "otp.h"
#include "stm32yyxx_ll_cortex.h"
#include "stm32yyxx_ll_rcc.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Function called to read the current micro second
* @param None
* @retval None
*/
uint32_t getCurrentMicros(void)
{
uint32_t m0 = HAL_GetTick();
__IO uint32_t u0 = SysTick->VAL;
uint32_t m1 = HAL_GetTick();
__IO uint32_t u1 = SysTick->VAL;
const uint32_t tms = SysTick->LOAD + 1;
if (m1 != m0) {
return (m1 * 1000 + ((tms - u1) * 1000) / tms);
} else {
return (m0 * 1000 + ((tms - u0) * 1000) / tms);
}
}
/**
* @brief Function called wto read the current millisecond
* @param None
* @retval None
*/
uint32_t getCurrentMillis(void)
{
return HAL_GetTick();
}
Code: Select all
SysTick->VAL
I opened all the included libraries, but couldn't find it there.