AN2274 Freescale Semiconductor / Motorola, AN2274 Datasheet - Page 15

no-image

AN2274

Manufacturer Part Number
AN2274
Description
Generic Tone Generation on the StarCore SC140 Core
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
3.3 Tests
The following MATLAB script displays the FFT of generated tones. A Hanning windowed FFT is used to measure
the output frequency. A typical frequency accuracy requirement is about ±1% of the nominal frequency. At an 8
kHz sampling rate, we must use at least 4096 samples (512 ms) to ensure that the error generated by the FFT is not
prejudicial.
Freescale Semiconductor
}
disp(’*** Generic Tone Generation on StarCore SC140 ***’)
disp(’ ’), disp(’ ’)
REF = ’.wav’; TONE_NAME = ’DTMF’; BITS
SAMPLES = 8 * 50; SILENCE = 8 * 50; SPACE
if TONE_NAME == ’DTMF’
elseif TONE_NAME == ’MFR1’
elseif TONE_NAME == ’MFR2’
else
end
if number_of_digits > 0
end
disp(’Test complete.’)
fclose(fid);
Generic Tone Generation on the StarCore™ SC140/SC1400 Cores, Rev. 1
Example 7. Frequency Response of Generated Tones
testcases[0].tone_component[1].silence_duration = 1000;
testcases[0].tone_component[1].frequency_1 = 440;
testcases[0].tone_component[1].level_1=0;
// Only one frequency is used - level is initialized to -63db
testcases[0].tone_component[1].frequency_2 = 0;
testcases[0].tone_component[1].level_2 = NOT_USED;
number_of_digits = 16; fid = fopen([’gen_dtmf’ REF], ’r’);
number_of_digits = 15; fid = fopen([’gen_mfr1’ REF], ’r’);
number_of_digits = 30; fid = fopen([’gen_mfr2’ REF], ’r’);
number_of_digits = 0; disp(’Unknown tone.’)
x = fread(fid, inf, ’short’);
disp([’Playing ’ TONE_NAME ’ generated tones...’])
wavplay(x, 8000);
for n = 1 : number_of_digits
end
disp([’Plotting ’ TONE_NAME ’ tone ’ int2str(n) ’...’])
out = x(SPACE + (n - 1) * (SAMPLES + SILENCE + SPACE) + ...
(1 : SAMPLES)) .* 2 ^ -(BITS - 1);
abscisse = linspace(0, 4000, SAMPLES / 2);
fft_out = 20*log10( abs( fft( hanning( SAMPLES) .* out)));
fft_out = fft_out - max(fft_out);
[a, b] = sort(-fft_out ( 1 : SAMPLES / 2));
[freq1, c] = sort(round(abscisse(1, b(1:2))));
figure, subplot(211)
plot(out), grid on
xlabel(’Sample #’)
title([TONE_NAME ’ Tone ’ int2str(n)])
subplot(212), plot(abscisse, fft_out(1 : SAMPLES / 2))
grid on, hold on
plot(freq(1), -a(c(1)), ’bo’), plot(freq1(2), -a(c(2)), ’ro’)
legend([’FFT of Tone ’ int2str(n)], ...
xlabel(’Frequency (Hz)’), ylabel(’Magnitude (dB)’)
[’F_1 = ’ int2str(freq1(1)) ’ Hz’], ...
[’F_2 = ’ int2str(freq1(2)) ’ Hz’])
= 16;
= SAMPLES + SILENCE;
Using and Testing the Generic Tone Generator
15

Related parts for AN2274