NavHAL 0.1.0
NAVRobotec's architecture-agnostic HAL for embedded systems.
Loading...
Searching...
No Matches
main.c File Reference

Print system clock and bus clocks over UART2. More...

#include "navhal.h"
Include dependency graph for main.c:

Macros

#define CORTEX_M4

Functions

int main (void)

Variables

hal_pll_config_t pll_cfg
 PLL configuration: 8 MHz HSE -> 168 MHz system clock.
hal_clock_config_t cfg
 System clock source configuration.

Detailed Description

Print system clock and bus clocks over UART2.

This example demonstrates:

  • Initializing the PLL for system clock configuration.
  • Initializing SysTick timer.
  • Initializing UART2 at 9600 baud for console output.
  • Printing SYSCLK, AHBCLK, APB1CLK, and APB2CLK periodically.

© 2025 NAVROBOTEC PVT. LTD. All rights reserved.

Macro Definition Documentation

◆ CORTEX_M4

#define CORTEX_M4

Function Documentation

◆ main()

int main ( void )

< Initialize system clock with PLL

< Initialize SysTick with 40 µs tick

< Initialize UART2 at 9600 baud

< Print SYSCLK label

< Print system clock

< Print APB1CLK label

< Print APB1 clock

< Print APB2CLK label

< Print APB2 clock

< Print AHBCLK label

< Print AHB clock

< Newline

< Wait 1 second

Variable Documentation

◆ cfg

Initial value:
= {
}
@ HAL_CLOCK_SOURCE_PLL
Phase-locked loop (derived clock)
Definition clock_types.h:27

System clock source configuration.

◆ pll_cfg

Initial value:
= {
.input_src = HAL_CLOCK_SOURCE_HSE,
.pll_m = 8,
.pll_n = 168,
.pll_p = 2,
.pll_q = 7
}
@ HAL_CLOCK_SOURCE_HSE
Definition clock_types.h:25

PLL configuration: 8 MHz HSE -> 168 MHz system clock.