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/

main.cpp

Committer:
SolderSplashLabs
Date:
2014-02-05
Revision:
2:ab9790e6d19e
Parent:
1:a4fac4fed052
Child:
3:065f35bc0f29

File content as of revision 2:ab9790e6d19e:

#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 )
{
float pwmStep = 0;
    
    // We want a 2KHz Pwm
    // Pwm1, 2 and 3 share a timer so use the same period
    pwm1.period_us(500);
    pwm4.period_ms(500);
    pwm7.period_ms(500);
    
    while (1)
    {
        pwmStep += 0.01;
        
        if(pwmStep >= 1.0) {
            pwmStep = 0;
        }
        
        pwm1 = pwmStep;
        pwm2 = pwmStep;
        pwm3 = pwmStep;
        
        pwm4 = pwmStep;
        pwm5 = pwmStep;
        pwm6 = pwmStep;
        
        pwm7 = pwmStep;
        pwm8 = pwmStep;
        
        wait(0.1);
    }   
}