diff options
Diffstat (limited to 'testhal')
-rw-r--r-- | testhal/STM32F37x/PWM-ICU/main.c | 26 | ||||
-rw-r--r-- | testhal/STM32F37x/PWM-ICU/mcuconf.h | 4 | ||||
-rw-r--r-- | testhal/STM32F37x/PWM-ICU/readme.txt | 2 |
3 files changed, 15 insertions, 17 deletions
diff --git a/testhal/STM32F37x/PWM-ICU/main.c b/testhal/STM32F37x/PWM-ICU/main.c index 5f2d8df4e..3a6232eec 100644 --- a/testhal/STM32F37x/PWM-ICU/main.c +++ b/testhal/STM32F37x/PWM-ICU/main.c @@ -38,7 +38,7 @@ static PWMConfig pwmcfg = { 10000, /* Initial PWM period 1S. */
pwmpcb,
{
- {PWM_OUTPUT_ACTIVE_HIGH, pwmc1cb},
+ {PWM_OUTPUT_ACTIVE_LOW, pwmc1cb},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL},
{PWM_OUTPUT_DISABLED, NULL}
@@ -61,7 +61,7 @@ static void icuperiodcb(ICUDriver *icup) { }
static ICUConfig icucfg = {
- ICU_INPUT_ACTIVE_HIGH,
+ ICU_INPUT_ACTIVE_LOW,
10000, /* 10kHz ICU clock frequency. */
icuwidthcb,
icuperiodcb,
@@ -85,13 +85,13 @@ int main(void) { chSysInit();
/*
- * Initializes the PWM driver 2 and ICU driver 3.
- * GPIOA15 is the PWM output.
+ * Initializes the PWM driver 5 and ICU driver 3.
+ * GPIOC0 is the PWM output.
* GPIOC6 is the ICU input.
* The two pins have to be externally connected together.
*/
- pwmStart(&PWMD2, &pwmcfg);
- palSetPadMode(GPIOA, 15, PAL_MODE_ALTERNATE(1));
+ pwmStart(&PWMD5, &pwmcfg);
+ palSetPadMode(GPIOC, 0, PAL_MODE_ALTERNATE(2));
icuStart(&ICUD3, &icucfg);
palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(2));
icuEnable(&ICUD3);
@@ -100,37 +100,35 @@ int main(void) { /*
* Starts the PWM channel 0 using 75% duty cycle.
*/
- pwmEnableChannel(&PWMD2, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 7500));
+ pwmEnableChannel(&PWMD5, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD5, 7500));
chThdSleepMilliseconds(5000);
/*
* Changes the PWM channel 0 to 50% duty cycle.
*/
- pwmEnableChannel(&PWMD2, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 5000));
+ pwmEnableChannel(&PWMD5, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD5, 5000));
chThdSleepMilliseconds(5000);
/*
* Changes the PWM channel 0 to 25% duty cycle.
*/
- pwmEnableChannel(&PWMD2, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 2500));
+ pwmEnableChannel(&PWMD5, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD5, 2500));
chThdSleepMilliseconds(5000);
/*
* Changes PWM period to half second the duty cycle becomes 50%
* implicitly.
*/
- pwmChangePeriod(&PWMD2, 5000);
+ pwmChangePeriod(&PWMD5, 5000);
chThdSleepMilliseconds(5000);
/*
* Disables channel 0 and stops the drivers.
*/
- pwmDisableChannel(&PWMD2, 0);
- pwmStop(&PWMD2);
+ pwmDisableChannel(&PWMD5, 0);
+ pwmStop(&PWMD5);
icuDisable(&ICUD3);
icuStop(&ICUD3);
- palClearPad(GPIOC, GPIOC_LED1);
- palClearPad(GPIOC, GPIOC_LED2);
/*
* Normal main() thread activity, in this demo it does nothing.
diff --git a/testhal/STM32F37x/PWM-ICU/mcuconf.h b/testhal/STM32F37x/PWM-ICU/mcuconf.h index 3da56f8a2..5778e8c9a 100644 --- a/testhal/STM32F37x/PWM-ICU/mcuconf.h +++ b/testhal/STM32F37x/PWM-ICU/mcuconf.h @@ -104,7 +104,7 @@ #define STM32_ICU_USE_TIM2 FALSE
#define STM32_ICU_USE_TIM3 TRUE
#define STM32_ICU_USE_TIM4 TRUE
-#define STM32_ICU_USE_TIM5 TRUE
+#define STM32_ICU_USE_TIM5 FALSE
#define STM32_ICU_TIM2_IRQ_PRIORITY 7
#define STM32_ICU_TIM3_IRQ_PRIORITY 7
#define STM32_ICU_TIM4_IRQ_PRIORITY 7
@@ -116,7 +116,7 @@ #define STM32_PWM_USE_TIM2 TRUE
#define STM32_PWM_USE_TIM3 FALSE
#define STM32_PWM_USE_TIM4 FALSE
-#define STM32_PWM_USE_TIM5 FALSE
+#define STM32_PWM_USE_TIM5 TRUE
#define STM32_PWM_TIM2_IRQ_PRIORITY 7
#define STM32_PWM_TIM3_IRQ_PRIORITY 7
#define STM32_PWM_TIM4_IRQ_PRIORITY 7
diff --git a/testhal/STM32F37x/PWM-ICU/readme.txt b/testhal/STM32F37x/PWM-ICU/readme.txt index e78925719..f1231603e 100644 --- a/testhal/STM32F37x/PWM-ICU/readme.txt +++ b/testhal/STM32F37x/PWM-ICU/readme.txt @@ -12,7 +12,7 @@ The demo runs on an STMicroelectronics STM32373C-EVAL board. ** Board Setup **
-- Connect PA15 and PC6 together.
+- Connect PC0 and PC6 together.
** Build Procedure **
|