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

Example application: Generate PWM on PB10 using TIM2 and print duty cycle over UART2. More...

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

Macros

#define CORTEX_M4

Functions

int main (void)

Detailed Description

Example application: Generate PWM on PB10 using TIM2 and print duty cycle over UART2.

  • Initializes SysTick timer with 40 µs tick.
  • Initializes UART2 at 9600 baud.
  • Configures PB10 as alternate function (AF1) for TIM2_CH3.
  • Initializes TIM2 for PWM output using HAL PWM driver.
  • Continuously ramps the duty cycle from 0% to 100% and prints it over UART2.

Macro Definition Documentation

◆ CORTEX_M4

#define CORTEX_M4

Function Documentation

◆ main()

int main ( void )

< Initialize SysTick with 40 µs tick

< Initialize UART2 at 9600 baud

< Set PB10 as alternate function

< AF1 for TIM2_CH3

< Initialize PWM handle on TIM2, channel 3

< Init PWM at 15 kHz, 10% duty cycle

< Start PWM output

< Variable for duty cycle update

< Update PWM duty cycle

< Increment duty cycle by 1%

< Reset to 0% after 100%

< Print current duty cycle over UART2

< Newline and carriage return

< Delay 10 ms