A simple program to output values to the DAC at top speed (using the AnalogOut class).
The answers to "how fast are the member functions?" are embedded in the comments, measured with a scope on pin 18
#include "mbed.h"
DigitalOut myled(LED1);
AnalogOut DACout(18);
int main() {
while (1) {
// how fast is the write member function?
// 4.8 to 4.9 uS
DACout.write(0);
DACout.write(1);
DACout.write(0);
DACout.write(1);
DACout.write(0);
DACout.write(1);
DACout.write(0);
DACout.write(1);
// the write_v function?
// 4.7 to 4.8 uS
DACout.write_v(0);
DACout.write_v(2.0);
DACout.write_v(0);
DACout.write_v(2.0);
DACout.write_v(0);
DACout.write_v(2.0);
DACout.write_v(0);
DACout.write_v(2.0);
// the write_mv function?
// 2.85 uS
DACout.write_mv(0);
DACout.write_mv(1500);
DACout.write_mv(0);
DACout.write_mv(1500);
DACout.write_mv(0);
DACout.write_mv(1500);
DACout.write_mv(0);
DACout.write_mv(1500);
}
}
