Skip to content

Commit ea0baf6

Browse files
author
Vineeth K
committed
MCU16GITHUB-1278 - FFT peakFrequency calculation corrected.
1 parent 4be3c73 commit ea0baf6

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

dspic33e-fft-dsplib/firmware/src/system_config/exp16/dspic33ep256gp506/main_fft_example.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
of an input signal and then the peak frequency is calculated.
1515
*******************************************************************************/
1616
/*******************************************************************************
17-
Copyright (c) 2012 released Microchip Technology Inc. All rights reserved.
17+
Copyright (c) 2025 released Microchip Technology Inc. All rights reserved.
1818
1919
Microchip licenses to you the right to use, modify, copy and distribute
2020
Software only when embedded on a Microchip microcontroller or digital signal
@@ -178,7 +178,7 @@ int main(void)
178178
VectorMax(FFT_BLOCK_LENGTH/2, output, &peakFrequencyBin);
179179

180180
/* Compute the frequency (in Hz) of the largest spectral component */
181-
peakFrequency = peakFrequencyBin*(SAMPLING_RATE/FFT_BLOCK_LENGTH);
181+
peakFrequency = (uint32_t) peakFrequencyBin*((float)SAMPLING_RATE/FFT_BLOCK_LENGTH);
182182
#ifdef TEST_MODE
183183
while(1)
184184
{

dspic33e-fft-dsplib/firmware/src/system_config/exp16/dspic33ep512gm710/main_fft_example.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
of an input signal and then the peak frequency is calculated.
1515
*******************************************************************************/
1616
/*******************************************************************************
17-
Copyright (c) 2012 released Microchip Technology Inc. All rights reserved.
17+
Copyright (c) 2025 released Microchip Technology Inc. All rights reserved.
1818
1919
Microchip licenses to you the right to use, modify, copy and distribute
2020
Software only when embedded on a Microchip microcontroller or digital signal
@@ -182,7 +182,7 @@ int main(void)
182182
VectorMax(FFT_BLOCK_LENGTH/2, output, &peakFrequencyBin);
183183

184184
/* Compute the frequency (in Hz) of the largest spectral component */
185-
peakFrequency = peakFrequencyBin*(SAMPLING_RATE/FFT_BLOCK_LENGTH);
185+
peakFrequency = (uint32_t) peakFrequencyBin*((float)SAMPLING_RATE/FFT_BLOCK_LENGTH);
186186

187187
#ifdef TEST_MODE
188188
while(1)

dspic33e-fft-dsplib/firmware/src/system_config/exp16/dspic33ep512mu810/main_fft_example.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
of an input signal and then the peak frequency is calculated.
1515
*******************************************************************************/
1616
/*******************************************************************************
17-
Copyright (c) 2012 released Microchip Technology Inc. All rights reserved.
17+
Copyright (c) 2025 released Microchip Technology Inc. All rights reserved.
1818
1919
Microchip licenses to you the right to use, modify, copy and distribute
2020
Software only when embedded on a Microchip microcontroller or digital signal
@@ -189,7 +189,7 @@ int main(void)
189189
VectorMax(FFT_BLOCK_LENGTH/2, output, &peakFrequencyBin);
190190

191191
/* Compute the frequency (in Hz) of the largest spectral component */
192-
peakFrequency = peakFrequencyBin*(SAMPLING_RATE/FFT_BLOCK_LENGTH);
192+
peakFrequency = (uint32_t) peakFrequencyBin*((float)SAMPLING_RATE/FFT_BLOCK_LENGTH);
193193

194194
#ifdef TEST_MODE
195195
while(1)

0 commit comments

Comments
 (0)