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.
Diff: main.cpp
- Revision:
- 0:cff63309a8af
--- /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