Simon Ford / Mbed 2 deprecated PWMTest
Revision:
0:c795e64e9eb0
Child:
1:4115ae4cbc76
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 01 11:01:48 2009 +0000
@@ -0,0 +1,34 @@
+// Testing PWM channel 0 vs channel 1 behaviour, sford
+
+#include "mbed.h"
+
+PwmOut pwm1(p26);
+PwmOut pwm2(p25);
+
+int main() {
+
+    uint32_t t = 10000;
+
+    // set period
+    LPC_PWM1->MR0 = t;
+    LPC_PWM1->LER |= 1 << 0;
+
+    while (1) {
+
+        // set pulsewidth to 100%
+        LPC_PWM1->MR1 = t;
+        LPC_PWM1->MR2 = t;
+        LPC_PWM1->LER |= 0x6;
+
+        // wait for update
+        while (LPC_PWM1->LER);
+
+        // set pulsewidth less than 100%
+        LPC_PWM1->MR1 = t - 500;
+        LPC_PWM1->MR2 = t - 500;
+        LPC_PWM1->LER |= 0x6;
+
+        // wait for update
+        while (LPC_PWM1->LER);
+    }
+}