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
Diff: main.cpp
- Revision:
- 0:5bd019c2fef1
- Child:
- 1:b11267086278
diff -r 000000000000 -r 5bd019c2fef1 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Mar 09 06:55:30 2017 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+
+PwmOut mypwm(PWM_OUT);
+PwmOut Ipwm(PB_5);
+
+DigitalOut myled(LED1);
+
+int main() {
+
+ 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);
+ }
+}
