Saw Wave Generator

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
ryood
Date:
Tue Aug 15 13:06:53 2017 +0000
Commit message:
firast commit

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r d51bfc20e42e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Aug 15 13:06:53 2017 +0000
@@ -0,0 +1,25 @@
+#include "mbed.h"
+
+AnalogOut aout(A2);
+
+const int maxAoutValue = 4096;
+const float samplingPeriod = 0.25f / maxAoutValue;
+
+int cnt = 0;
+
+void tick()
+{
+    cnt++;
+    if (cnt == maxAoutValue) {
+        cnt = 0;
+    }
+    aout.write_u16(cnt << 4);
+}
+
+int main()
+{
+    Ticker t;
+    t.attach(&tick, samplingPeriod);
+
+    for (;;) {}
+}
diff -r 000000000000 -r d51bfc20e42e mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Aug 15 13:06:53 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/fd96258d940d
\ No newline at end of file