Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Nucleo_pwm by
main.cpp
- Committer:
- ronaldhklee
- Date:
- 2017-03-09
- Revision:
- 1:b11267086278
- Parent:
- 0:5bd019c2fef1
- Child:
- 2:004873c585fe
File content as of revision 1:b11267086278:
#include "mbed.h"
PwmOut mypwm(PWM_OUT);
PwmOut Ipwm(PB_5);
DigitalOut myled(LED1);
int main() {
    //외부에 8MHz x-tal 부착해야 됨.
    mypwm.period_us(100);       //10KHz
    mypwm.pulsewidth_us(10);    //Duty rate: 10%
    
    Ipwm.period(0.0001);        //10KHz
    Ipwm.pulsewidth(0.000001);  //Duty rate: 1%, Duty rate는 1% 이하로 설정이 안됨.
  
    printf("pwm set to %.2f %%\n", mypwm.read() * 100);
    
    while(1) {
        myled = !myled;
        wait(1);
    }
}
            
    