diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-04-05 18:21:00 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-04-05 18:21:00 +0000 |
commit | ad009f46d58f4f555cd412aa2f2a267da01db4e0 (patch) | |
tree | 18b4e9fd44f637c664c075b9d611465ed015fc60 /testhal/STM32 | |
parent | c4fec713d238a4396ee5693c986e3d25a74082e5 (diff) | |
download | ChibiOS-ad009f46d58f4f555cd412aa2f2a267da01db4e0.tar.gz ChibiOS-ad009f46d58f4f555cd412aa2f2a267da01db4e0.tar.bz2 ChibiOS-ad009f46d58f4f555cd412aa2f2a267da01db4e0.zip |
STM32 PWM driver optimization, changed the behavior of pwmChangePeriod().
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2869 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal/STM32')
-rw-r--r-- | testhal/STM32/PWM-ICU/main.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/testhal/STM32/PWM-ICU/main.c b/testhal/STM32/PWM-ICU/main.c index 3f7b6423e..1fd56c33a 100644 --- a/testhal/STM32/PWM-ICU/main.c +++ b/testhal/STM32/PWM-ICU/main.c @@ -89,7 +89,7 @@ int main(void) { palSetPad(IOPORT3, GPIOC_LED);
/*
- * Initializes the PWM driver 1.
+ * Initializes the PWM driver 1 and ICU driver 4.
*/
pwmStart(&PWMD1, &pwmcfg);
palSetPadMode(IOPORT1, 8, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
@@ -98,26 +98,32 @@ int main(void) { chThdSleepMilliseconds(2000);
/*
- * Starts the channel 0 using 25% duty cycle.
+ * Starts the PWM channel 0 using 75% duty cycle.
*/
- pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 2500));
+ pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 7500));
chThdSleepMilliseconds(5000);
/*
- * Changes the channel 0 to 75% duty cycle.
+ * Changes the PWM channel 0 to 50% duty cycle.
*/
- pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 7500));
+ pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
+ chThdSleepMilliseconds(5000);
+
+ /*
+ * Changes the PWM channel 0 to 25% duty cycle.
+ */
+ pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 2500));
chThdSleepMilliseconds(5000);
/*
- * Changes PWM period to half second and duty cycle to 50%.
+ * Changes PWM period to half second the duty cycle becomes 50%
+ * implicitly.
*/
pwmChangePeriod(&PWMD1, 5000);
- pwmEnableChannel(&PWMD1, 0, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000));
chThdSleepMilliseconds(5000);
/*
- * Disables channel 0.
+ * Disables channel 0 and stops the drivers.
*/
pwmDisableChannel(&PWMD1, 0);
pwmStop(&PWMD1);
|