although this question may be trival, I do not quite understand the results of my work. I followed bare metal programming articles and tried to implement some basic functionalities on my Nucleo board with STM32H723 without any external libraries. I understand most of it, but some article mentioned that I need to enable SysCfg in order to use systick.
static inline void systick_init(uint32_t ticks) {
if ((ticks - 1) > 0xffffff) return; // Systick timer is 24 bit
SYSTICK->LOAD = ticks - 1;
SYSTICK->VAL = 0;
SYSTICK->CTRL = BIT(0) | BIT(1) | BIT(2); // Enable systick
//RCC->APB4ENR |= BIT(1); // WHY NOT NEEDED?
}
What I am observing, is that I do not need last line (the commented out one), which is mentioned SysCfg enabling. I am not touching this register in any other part of my code, yet interrupt is still working. I even checked startup.s file which Cube generated for me and all I can see there is initialization of interrupt vector. Is it because of power mode? SysCfg is disabled by default only in low power?
SysTick is a core Cortex-M7 peripheral and it is independent of the SYSCFG peripheral.
but some article mentioned that I need to enable SysCfg in order to use systick.
Do not trust internet "articles". Use the documentation.
Do not use magic numbers - use definitions from STM32H7 CMSIS
#include "stm32h7xx.h"
void SysTick_Init(uint32_t ticks)
{
// Set the reload register
SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1;
// Set the SysTick priority (optional)
NVIC_SetPriority(SysTick_IRQn, 0);
// Reset the current value register
SysTick->VAL = 0;
// Select processor clock (HCLK) as SysTick clock source
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
SysTick_CTRL_TICKINT_Msk |
SysTick_CTRL_ENABLE_Msk;
}
void SysTick_Handler(void)
{
// Handle the SysTick interrupt (e.g., increment a tick counter)
}
I even checked startup.s
Cube does not place any peripheral initialization there. Only in .c
source files.
Is it because of power mode? SysCfg is disabled by default only in low power?
Using misleading sources of information leads to wrong conclusions. SysCfg
is disabled by default and if you want its features you need to enable it.
But SysTick is independent and not related to this peripheral.