very simple 4ch PWM output demo for "mbed LPC824"

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
nxpfan
Date:
Wed Dec 17 01:32:34 2014 +0000
Commit message:
4ch PWM output demo

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r a7f40d4e5c58 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Dec 17 01:32:34 2014 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"
+
+#define     PI          3.14159265
+
+PwmOut pwm[]    = {
+    PwmOut( dp6 ),
+    PwmOut( dp7 ),
+    PwmOut( dp8 ),
+    PwmOut( dp9 ),
+};
+
+int main()
+{
+    int     count   = 0;
+    float   t       = PI / 40.0;
+
+    while(1) {
+        for ( int i = 0; i < 4; i++ ) {
+            pwm[ 0 ]    = powf( sin( t * (float)(count +  0) ), 2.0 );
+            pwm[ 1 ]    = powf( sin( t * (float)(count +  5) ), 2.0 );
+            pwm[ 2 ]    = powf( sin( t * (float)(count + 10) ), 2.0 );
+            pwm[ 3 ]    = powf( sin( t * (float)(count + 15) ), 2.0 );
+        }
+        wait_ms( 20 );
+        count++;
+    }
+}
+
diff -r 000000000000 -r a7f40d4e5c58 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Dec 17 01:32:34 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file