2023-08-18 06:39 AM
In ultrasoun library has a bug. If change you in fft_app.h FFT_OUTPUT program is not compiled. Please change code like this
static void FFT_Thread(void const *argument)
{
(void) argument;
#if (configUSE_APPLICATION_TASK_TAG == 1 && defined(TASK_FFT_DEBUG_PIN))
vTaskSetApplicationTaskTag(NULL, (TaskHookFunction_t)TASK_FFT_DEBUG_PIN);
#endif
#ifdef DATA_TEST
static uint16_t usbTestData = 0;
#endif
#if (FFT_OUTPUT == FFT_AVERAGE)
uint16_t nAccTotal = 10;
uint16_t nAcc = 0;
#endif
FFT_Lib_Init(512, 0.5f);
for (;;)
{
osSemaphoreWait(fft_data_input_sem_id, osWaitForever);
FFT_Process(&audio_fft_instance, audio_fft_out);
#if (FFT_OUTPUT == FFT_RAW)
if (com_status == HS_DATALOG_USB_STARTED)
{
USBD_WCID_STREAMING_FillTxDataBuffer(&USBD_Device, 0, (uint8_t *) audio_fft_out,
sizeof(float) * audio_fft_instance.init_params.FFT_len / 2);
}
#elif (FFT_OUTPUT == FFT_AVERAGE)
arm_add_f32(audio_fft_out, FFT_Average, FFT_Average, audio_fft_instance.init_params.FFT_len / 2);
nAcc++;
if (nAcc == nAccTotal)
{
arm_scale_f32(FFT_Average, 1.0f / (float)nAcc, FFT_Average, audio_fft_instance.init_params.FFT_len / 2);
if (com_status == HS_DATALOG_USB_STARTED)
{
USBD_WCID_STREAMING_FillTxDataBuffer(&USBD_Device, 0, (uint8_t *)FFT_Average,
sizeof(float) * audio_fft_instance.init_params.FFT_len / 2);
}
memset((uint8_t *)FFT_Average, 0, audio_fft_instance.init_params.FFT_len / 2);
nAcc = 0;
}
#elif (FFT_OUTPUT == FFT_WEIGHTED_AVERAGE)
uint32_t i;
for (i = 0; i < audio_fft_instance.init_params.FFT_len / 2; i++)
{
audio_fft_out[i] = FFT_Average[i] * 0.97f + audio_fft_out[i] * 0.03f;
FFT_Average[i] = audio_fft_out[i];
}
if (com_status == HS_DATALOG_USB_STARTED)
{
USBD_WCID_STREAMING_FillTxDataBuffer(&USBD_Device, 0, (uint8_t *)FFT_Average,
sizeof(float) * audio_fft_instance.init_params.FFT_len / 2);
}
#endif
#ifdef DATA_TEST
uint16_t i = 0;
int16_t *p16 = (int16_t *)dataOut;
for (i = 0; i < 4; i++)
{
*p16++ = usbTestData++;
}
#endif
}
}
2023-08-21 08:07 AM
Hi @karakasali ,
Welcome to ST community =)
thank you for your input, but would you mind explaining what is the problem with the default library?
Niccolò