main.cpp

Committer:
simon
Date:
2009-12-01
Revision:
0:c795e64e9eb0
Child:
1:4115ae4cbc76

File content as of revision 0:c795e64e9eb0:

// 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);
    }
}