PwmDAC is a library to run more the one PWM channel and channel updates at the time. Maximum PWM frequency is 48MHz. You can use for in example for rgb applications or as a multi channel dac with connected active lowpass. Written for mbed LPC1768. Not completly tested. I will upload my results as soon as possible. Although some deeper informations and LTSpice simulations

Dependents:   DiscoTech filter_implement

Revision:
1:381bd99d10a4
Parent:
0:13e0b9ea312f
--- a/PwmDAC.cpp	Sun Sep 15 22:20:47 2013 +0000
+++ b/PwmDAC.cpp	Sat Sep 21 08:47:27 2013 +0000
@@ -43,9 +43,9 @@
     
     for(int i = 1; i < 7; i++) {                                            // update ch. 1-6
         *MR[i] = 0;
-        LPC_PWM1->LER |= (1 << i);
     }
-    
+    LPC_PWM1->LER |= (0x3F << 1);
+        
     LPC_PWM1->TCR |= (1 << 3) | (1 << 0);                                   // enable PWM and Timer (PWM unit)
                                                                             // ==> output update from MR1-6 are load and
                                                                             // enabled with LPC_PWM1->LER Bit 6:1 set to "1"
@@ -113,9 +113,9 @@
             _pulsewidth[i] = duty[i] / 100.0 * _period;
             _steps[i] = (uint32_t) ((double) SYS_CLK * _pulsewidth[i]);
             *MR[i+1] = _steps[i];
-            LPC_PWM1->LER |= (1 << (i+1));
         }
-    }    
+    }
+    LPC_PWM1->LER |= (0x3F << 1);    
 }
 
 void PwmDAC::updatePulsewidth(double pulsewidth[]) {
@@ -125,9 +125,9 @@
             _pulsewidth[i] = pulsewidth[i];
             _steps[i] = (uint32_t) ((double) SYS_CLK * pulsewidth[i]);
             *MR[i+1] = _steps[i];
-            LPC_PWM1->LER |= (1 << (i+1));
         }
-    }    
+    }
+    LPC_PWM1->LER |= (0x3F << 1);
 }
     
 void PwmDAC::updateSteps(uint32_t steps[]) {
@@ -137,21 +137,21 @@
             _pulsewidth[i] = _duty[i] * _period;
             _steps[i] = steps[i];
             *MR[i+1] = steps[i];
-            LPC_PWM1->LER |= (1 << (i+1));
         }
-    }    
+    }
+    LPC_PWM1->LER |= (0x3F << 1);    
 }
 
 void PwmDAC::stop() {
     for(int i = 0; i < 6; i++) {
         *MR[i+1] = 0;
-        LPC_PWM1->LER |= (1 << (i+1));
     }    
+    LPC_PWM1->LER |= (0x3F << 1);
 }
 
 void PwmDAC::start() {
     for(int i = 0; i < 6; i++) {
         *MR[i+1] = _steps[i];
-        LPC_PWM1->LER |= (1 << (i+1));
-    }    
+    }
+    LPC_PWM1->LER |= (0x3F << 1);   
 }
\ No newline at end of file