This is a small program we use to see how long something takes. It runs the code in the while loop a lot of times and prints out how many us it took. Then this can be divided by the number of iterations to find the time/clock cycles for each iteration.
Revision 0:cff63309a8af, committed 2013-07-08
- Comitter:
- avbotz
- Date:
- Mon Jul 08 03:58:56 2013 +0000
- Commit message:
- Initial commit.
Changed in this revision
diff -r 000000000000 -r cff63309a8af main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jul 08 03:58:56 2013 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" +#include "dsp.h" + +Serial pc(USBTX, USBRX); +DigitalOut myled(LED1); +Timer tim; + +int main() { + unsigned int i = 0; + + q15_t lad[5], ref[6]; + q15_t state[1029], in[1024], out[1024]; + // this loop takes 4 assembly instructions to run per cycle + // http://www.wolframalpha.com/input/?i=%282731+us%2F65536%29%2F%281%2F24000000Hz%29 + arm_iir_lattice_instance_q15 filter = {5, state, ref, lad}; + tim.start(); + while (i<100) + { + arm_iir_lattice_q15(&filter, in, out, 1024); + i++; + } + tim.stop(); + pc.printf("%d us\n\r",tim.read_us()); +} +//mbed LPC1768 runs at 96 MHz +//2731 us=65536 cycles \ No newline at end of file
diff -r 000000000000 -r cff63309a8af mbed-dsp.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-dsp.lib Mon Jul 08 03:58:56 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-dsp/#fdd22bb7aa52
diff -r 000000000000 -r cff63309a8af mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jul 08 03:58:56 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b \ No newline at end of file