Ura
Dependencies: CMSIS_DSP_401 mbed
Diff: main.cpp
- Revision:
- 2:707eb5bc5dfc
- Parent:
- 1:9b1df0b2507d
- Child:
- 3:1f56b8f439a1
--- a/main.cpp Fri Oct 03 14:35:00 2014 +0000 +++ b/main.cpp Fri Oct 03 14:52:53 2014 +0000 @@ -27,15 +27,15 @@ void samplingCallback() { - /* + // Read from the ADC and store the sample data - samples[sampleCounter] = (1023 * left) - 511.0; + samples[sampleCounter] = (1023 * left.read()) - 511.0; // Complex FFT functions require a coefficient for the imaginary part of the input. // Since we only have real data, set this coefficient to zero. samples[sampleCounter+1] = 0.0; // Update sample buffer position and stop after the buffer is filled sampleCounter += 2; - */ + if (sampleCounter >= FFT_SIZE*2) { samplingTimer.detach(); } @@ -104,15 +104,15 @@ //arm_cfft_radix2_f32(arm_cfft_radix2_instance_f32*S, samples); arm_cfft_f32(S, samples, 0, 1); for(int i = 0;i < FFT_SIZE*2;++i) - printf("% 8.2f ",samples[i]); - printf("\r\n"); + pc.printf("% 8.2f ",samples[i]); + pc.printf("\r\n"); // Calculate magnitude of complex numbers output by the FFT. arm_cmplx_mag_f32(samples, magnitudes, FFT_SIZE); for(int i = 0;i < FFT_SIZE;++i) - printf("% 8.2f ",magnitudes[i]); - printf("\r\n"); + pc.printf("% 8.2f ",magnitudes[i]); + pc.printf("\r\n"); arm_max_f32(magnitudes, FFT_SIZE, &maxValue, &testIndex); - printf("MAX value at magnitudes[%d] : %+ 8.2f\r\n", testIndex, maxValue); + pc.printf("MAX value at magnitudes[%d] : %+ 8.2f\r\n", testIndex, maxValue); // Wait for user confirmation to restart audio sampling. //pc.getc(); wait(1);