FRDM-K64 PWM basic example using mbed

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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;

        }

    }

}

附件
无评分
版本历史
最后更新:
‎06-27-2014 11:04 AM
更新人: