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.
Diff: main.cpp
- Revision:
- 2:4857a7cbb9da
- Parent:
- 1:284229960d6a
- Child:
- 3:f04c8a88a27d
--- a/main.cpp Wed Jan 24 22:59:37 2018 +0000
+++ b/main.cpp Wed Jan 23 17:56:08 2019 +0000
@@ -1,7 +1,7 @@
// Lab 3 Example Program 2
// -----------------------
// Periodically write to the AnalogOut to create a sine wave
-// Alternate between two fixed frequencies every 5 sec
+// Alternate between two fixed frequencies every 30 sec
//
// THIS VERSION HAS DEBUGGING CODE USING THE SERIAL PORT
@@ -17,7 +17,7 @@
Thread debugT ;
Serial pc(USBTX, USBRX); // tx, rx, useful for debugging
-// Put a simple reprsentation of the sine wave
+// Put a simple representation of the sine wave
// to the serial output. ONLY at low frequency
void debug(int index) {
int sine4 = sine[index] >> 11 ; // get top 5 bits
@@ -37,7 +37,7 @@
}
// ---- end of debugging code ---------
-// Function called every periodically
+// Function called periodically
// Write new value to AnalogOut
void writeAout() {
ao.write_u16(sine[index]) ;
@@ -53,11 +53,11 @@
while (true) {
pc.printf("Update at 64 x 100ms giving about 0.15Hz\n");
tick.attach_us(callback(&writeAout), update_us); // setup ticker to write to AnalogOut
- Thread::wait(30000) ; // wait 30 sec - 30000ms
+ wait(30.0) ; // wait 30 sec - 30000ms
update_us = 150000 ; // 150ms
pc.printf("Update at 64 x 150ms giving about 0.1Hz\n");
tick.attach_us(callback(&writeAout), update_us); // setup ticker to write to AnalogOut
- Thread::wait(30000) ; // wait 30 sec - 30000ms
+ wait(30.0) ; // wait 30 sec - 30000ms
update_us = 100000 ; // 100ms
}
}