Example application: Generate PWM on PB10 using TIM2 and print duty cycle over UART2. More...
#include "navhal.h"
Macros | |
| #define | CORTEX_M4 |
Functions | |
| int | main (void) |
Example application: Generate PWM on PB10 using TIM2 and print duty cycle over UART2.
| #define CORTEX_M4 |
| 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