From 3e90915d48e11736c092a60b9cde9a08a704c2b6 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Mon, 26 Oct 2020 12:45:50 -0700 Subject: [PATCH] PWM works --- firmware/cfg/mcuconf.h | 2 +- firmware/main.cpp | 8 ++++++-- firmware/pwm.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/firmware/cfg/mcuconf.h b/firmware/cfg/mcuconf.h index fa69762..9aa650c 100644 --- a/firmware/cfg/mcuconf.h +++ b/firmware/cfg/mcuconf.h @@ -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 diff --git a/firmware/main.cpp b/firmware/main.cpp index 806e80e..683cdfb 100644 --- a/firmware/main.cpp +++ b/firmware/main.cpp @@ -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(); diff --git a/firmware/pwm.cpp b/firmware/pwm.cpp index 4bb546e..2df18f4 100644 --- a/firmware/pwm.cpp +++ b/firmware/pwm.cpp @@ -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