PWM works

This commit is contained in:
Matthew Kennedy 2020-10-26 12:45:50 -07:00
parent 7a94321773
commit 3e90915d48
3 changed files with 11 additions and 7 deletions

View File

@ -112,7 +112,7 @@
/*
* PWM driver system settings.
*/
#define STM32_PWM_USE_ADVANCED FALSE
#define STM32_PWM_USE_ADVANCED TRUE
#define STM32_PWM_USE_TIM1 TRUE
#define STM32_PWM_USE_TIM2 FALSE
#define STM32_PWM_USE_TIM3 TRUE

View File

@ -7,10 +7,10 @@
// 400khz / 1024 = 390hz PWM
// TODO: this is wired to an inverted output, what do?
Pwm heaterPwm(PWMD1, 1, 400000, 1024);
Pwm heaterPwm(PWMD1, 0, 400'000, 1024);
// 48MHz / 1024 = 46.8khz PWM
Pwm pumpDac(PWMD3, 1, 48000000, 1024);
Pwm pumpDac(PWMD3, 0, 48'000'000, 1024);
/*
* Application entry point.
@ -21,6 +21,10 @@ int main() {
InitCan();
palSetPadMode(GPIOA, 6, PAL_MODE_ALTERNATE(1));
adcStart(&ADCD1, nullptr);
heaterPwm.Start();
pumpDac.Start();

View File

@ -17,10 +17,10 @@ void Pwm::Start()
m_counterPeriod,
nullptr,
{
{PWM_OUTPUT_ACTIVE_HIGH, nullptr},
{PWM_OUTPUT_ACTIVE_HIGH, nullptr},
{PWM_OUTPUT_ACTIVE_HIGH, nullptr},
{PWM_OUTPUT_ACTIVE_HIGH, nullptr}
{PWM_OUTPUT_ACTIVE_HIGH | PWM_COMPLEMENTARY_OUTPUT_ACTIVE_LOW, nullptr},
{PWM_OUTPUT_ACTIVE_HIGH | PWM_COMPLEMENTARY_OUTPUT_ACTIVE_LOW, nullptr},
{PWM_OUTPUT_ACTIVE_HIGH | PWM_COMPLEMENTARY_OUTPUT_ACTIVE_LOW, nullptr},
{PWM_OUTPUT_ACTIVE_HIGH | PWM_COMPLEMENTARY_OUTPUT_ACTIVE_LOW, nullptr}
},
0,
0