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:
0:287341b775cc
Child:
1:a4fac4fed052
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 05 01:21:45 2014 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+
+PwmOut pwm1(P1_24);
+PwmOut pwm2(P1_25);
+PwmOut pwm3(P1_26);
+
+
+PwmOut pwm4(P0_8);
+PwmOut pwm5(P0_9);
+PwmOut pwm6(P1_15);
+
+PwmOut pwm7(P0_21);
+PwmOut pwm8(P0_22);
+
+
+int main ( void )
+{
+    // Pwm1, 2 and 3 share a timer so use the same period
+    pwm1.period_ms(20);
+    pwm4.period_ms(20);
+    pwm7.period_ms(20);
+    
+    while (1)
+    {
+        pwm1 = pwm1 + 0.01;
+        wait(0.1);
+        if(pwm1 == 1.0) {
+            pwm1 = 0;
+        }
+        
+        pwm2 = pwm1;
+        pwm3 = pwm2;
+        
+        // --
+        
+        pwm4 = pwm4 + 0.01;
+        wait(0.1);
+        if(pwm1 == 1.0) {
+            pwm1 = 0;
+        }
+        
+        pwm5 = pwm4;
+        pwm6 = pwm5;
+        
+        // --
+        
+        pwm7 = pwm7 + 0.01;
+        wait(0.1);
+        if(pwm7 == 1.0) {
+            pwm7 = 0;
+        }
+        
+        pwm8 = pwm7;
+    }   
+}