DipCortex PwmOut Example

Dependencies:   mbed

Fork of DipCortex-PWM by Carl - SolderSplash Labs

PwmOut Example for the DipCortex

Mbed PwmOut library can use the following pins :

Timer/Match Register	Pinout Options
CT16B0/MR0	p15 (P0_8) and p19 (p1_13)
CT16B0/MR1	p16 (P0_9) and p20 (p1_14)
CT16B0/MR2	p27 (P1_15) and p27 (p1_15)

CT16B1/MR0	p24 (P0_21)
CT16B1/MR1	p9 (P0_22) and p38 (P1_23)

CT32B0/MR0	p17 (P1_24) and p26 (P0_18)
CT32B0/MR1	p29 (P1_25) and p25 (P0_19)
CT32B0/MR2	p35 (P1_26)

Please refer to the Pin Out diagram for the WiFi DipCortex to avoid Pins used to communicate with the CC3000 http://www.soldersplash.co.uk/products/wifi-dipcortex/

Revision:
1:a4fac4fed052
Parent:
0:287341b775cc
Child:
2:ab9790e6d19e
--- a/main.cpp	Wed Feb 05 01:21:45 2014 +0000
+++ b/main.cpp	Wed Feb 05 01:28:51 2014 +0000
@@ -4,7 +4,6 @@
 PwmOut pwm2(P1_25);
 PwmOut pwm3(P1_26);
 
-
 PwmOut pwm4(P0_8);
 PwmOut pwm5(P0_9);
 PwmOut pwm6(P1_15);
@@ -12,9 +11,10 @@
 PwmOut pwm7(P0_21);
 PwmOut pwm8(P0_22);
 
-
 int main ( void )
 {
+float pwmStep = 0;
+    
     // Pwm1, 2 and 3 share a timer so use the same period
     pwm1.period_ms(20);
     pwm4.period_ms(20);
@@ -22,34 +22,23 @@
     
     while (1)
     {
-        pwm1 = pwm1 + 0.01;
-        wait(0.1);
-        if(pwm1 == 1.0) {
-            pwm1 = 0;
+        pwmStep += 0.01;
+        
+        if(pwmStep >= 1.0) {
+            pwmStep = 0;
         }
         
-        pwm2 = pwm1;
-        pwm3 = pwm2;
-        
-        // --
-        
-        pwm4 = pwm4 + 0.01;
-        wait(0.1);
-        if(pwm1 == 1.0) {
-            pwm1 = 0;
-        }
+        pwm1 = pwmStep;
+        pwm2 = pwmStep;
+        pwm3 = pwmStep;
         
-        pwm5 = pwm4;
-        pwm6 = pwm5;
-        
-        // --
+        pwm4 = pwmStep;
+        pwm5 = pwmStep;
+        pwm6 = pwmStep;
         
-        pwm7 = pwm7 + 0.01;
+        pwm7 = pwmStep;
+        pwm8 = pwmStep;
+        
         wait(0.1);
-        if(pwm7 == 1.0) {
-            pwm7 = 0;
-        }
-        
-        pwm8 = pwm7;
     }   
 }