-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPWMout.c
More file actions
30 lines (28 loc) · 1.04 KB
/
PWMout.c
File metadata and controls
30 lines (28 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
* PWM.c
*
* Created on: 20 èþëÿ 2017 ã.
* Author: alpha-user
*/
#include "hal.h"
#include "PWMout.h"
void PWMInit() {
palSetPadMode(GPIOB, PWM_PIN , PAL_MODE_STM32_ALTERNATE_PUSHPULL);
static const PWMConfig pwm_config1 = {
.frequency = 10000,
.period = 10000,
.callback = NULL,
.channels = {
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_DISABLED, NULL}
},
.cr2 = 0,
.dier = 0
};
pwmStart(&PWMD4,&pwm_config1);
}
void PWMSetDutyCycle (uint8_t duty) {
pwmEnableChannel(&PWMD4, 2, (uint16_t)2550000/duty);
}