FRDM-K64 PWM basic example using mbed

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRDM-K64 PWM basic example using mbed

FRDM-K64 PWM basic example using mbed

Here you can find both the code and project files for the PWM project, in this example a single PWM channel belonging to the Flextimer 0 (PTC10/FTM_CH12) is enabled to provide a PWM signal with a 500ms period, the signal's duty cycle increases its period every 100ms, to visually observe the signal connect a led from the A5 pin in the J4 connector to GND (J3, pin 14).

Code:

#include "mbed.h"

//PWM output channel

PwmOut PWM1(A5);

int main()

{

    PWM1.period_ms(500);

    int x;

    x=1;

   

    while(1)

    {

        PWM1.pulsewidth_ms(x);

        x=x+1;

        wait(.1);

        if(x==500)

        {

            x=1;

        }

    }

}

Attachments
No ratings
Version history
Last update:
‎06-27-2014 11:04 AM
Updated by: