ArmfulKST / Mbed 2 deprecated STM32L432PWM2

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
f3d
Date:
Tue Mar 26 12:41:30 2019 +0000
Parent:
0:18d54d648967
Commit message:
Complimentary single channel PWM (no deadtime)

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Mar 26 12:37:18 2019 +0000
+++ b/main.cpp	Tue Mar 26 12:41:30 2019 +0000
@@ -8,13 +8,12 @@
 For register definitions see here:
 https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L432xC/device/stm32l432xx.h
 */
-#define BUF_SIZE 99
 
 // Using the MBED libraries to configure the PWM outputs (its easier than 
 // calculating all of the register contents by hand)
 DigitalOut myled(LED1);
 PwmOut  PhaATop(PA_8); 
-
+PwmOut  PhaABottom(PA_7);
 void initTimer1()
 {    
     
@@ -23,8 +22,8 @@
     TIM1->PSC = 1;
     TIM1->ARR = PWM_PERIOD_COUNT;
     TIM1->CCR1 = PWM_PERIOD_COUNT/4; // 25% duty
-    // Enable channel 1
-    TIM1->CCER = 1;
+    // Enable channel 1 and its complimentary output
+    TIM1->CCER = (1 << 0) + (1 << 2);
     TIM1->SR = 0;      // Clear flags.    
     TIM1->CR1 |= 1; // enable counter