Thomas Gartlan
/
DSP1_Timer_ex9_3
Using the Timer to test the maximum speed of the ADC and DAC
Diff: main.cpp
- Revision:
- 0:23ff2f1bb142
- Child:
- 1:6bb2d13644e8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 07 12:56:43 2017 +0000 @@ -0,0 +1,39 @@ +#include "mbed.h" +Timer t; +Serial pc(USBTX, USBRX); +AnalogOut Aout(p18); +AnalogIn Ain(p20); + +DigitalOut myled(LED1); + +int main() { + float value = 0; + unsigned short value2 = 0; + while(1) { + t.start(); + pc.printf("Hello World!\n\r"); + t.stop(); + pc.printf("time take was %f seconds\n", t.read()); + t.reset(); + myled = 1; + wait(2); + myled = 0; + wait(2); + pc.printf("Testing ADC time!\n\r"); + t.reset(); + t.start(); + //value = Ain; + value2 = Ain.read_u16(); + t.stop(); + pc.printf("ADC took %f seconds\n", t.read()); + wait(2); + pc.printf("Testing DAC time!\n\r"); + t.reset(); + t.start(); + Aout =value; + t.stop(); + pc.printf("DAC took %f seconds\n", t.read()); + wait(2); + + } +}