pwm works

This commit is contained in:
Wolfgang Hottgenroth
2018-01-16 17:56:07 +01:00
parent 3aa6bbc9a6
commit 4ee20b974a
20 changed files with 920 additions and 618 deletions

View File

@ -21,6 +21,7 @@
#include "stm32f1xx_hal.h"
#include "blinky.h"
#include "pwm.h"
void my_setup_1() {
@ -42,6 +43,7 @@ void my_errorHandler() {
void my_setup_2() {
blinkyInit();
pwmInit();
}

39
my_src/pwm.c Normal file
View File

@ -0,0 +1,39 @@
/*
* pwm.c
*
* Created on: Jan 16, 2018
* Author: wn
*/
#include "pwm.h"
#include "stm32f1xx_hal.h"
#include <PontCoopScheduler.h>
extern TIM_HandleTypeDef htim3;
void pwmExec(void *handle) {
}
void pwmInit() {
// schAdd(pwmExec, NULL, 0, 1000);
__HAL_TIM_SET_AUTORELOAD(&htim3, 10000);
__HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_1, 200);
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
__HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_2, 1000);
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
__HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_3, 2000);
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3);
__HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_4, 8000);
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4);
}

15
my_src/pwm.h Normal file
View File

@ -0,0 +1,15 @@
/*
* pwm.h
*
* Created on: Jan 16, 2018
* Author: wn
*/
#ifndef PWM_H_
#define PWM_H_
void pwmInit();
#endif /* PWM_H_ */