I created a talk-through with scaler layout in AWE Designer. I can generate target files and run this layout on my STM32F407 board, input audio from USB and output audio to headphone. I can change scaler1Gain in software and hear/view the corresponding change in amplitude of output signal. All good.
Instead of USB input audio, I want to use ADC audio input. I started with a working STM32CubeIDE project (not created from Audio Weaver) that takes ADC input and sends to headphone, and added in the elements needed to work with AWE-generated target files. I am using DMA for ADC input as well as for I2S output.
AWEInstanceInit() goes well; I have checked to returns from aweInitPin and awe_init, and all is well there.
My awe_loadAWBfromArray is successful.
Before I attempt to import or export samples, I use
bAudioIsStarted = awe_audioIsStarted(&g_AWEInstance);
bLayoutValid = awe_layoutIsValid(&g_AWEInstance);
Both functions return 1, signalling success. My “board alive” LED is blinking away.
My code for I2S DMA callbacks is shown below.
My send_to_AWE_buffer is filled with good numbers from ADC, same value in R and L channels for each sample.
My receive_from_AWE_buffer is always filled with only zeros.
Each call to awe_audioImportSamples and awe_audioExportSamples returns 0, so these functions appear to believe all is well. Since I cannot “step into” awe_audioExportSamples , I am stymied as to how to progress.
Are you able to suggest reasons why my receive_from_AWE_buffer might be eternally zero despite success indicators and a healthy input buffer? I am having trouble devising a next troubleshooting step. Thank you so much for your advice.
Declarations:
fract16 send_to_AWE_buffer[4*AUDIO_BLOCK_SIZE];
INT16 receive_from_AWE_buffer[4*AUDIO_BLOCK_SIZE];
Code executed for HAL_I2S_TxHalfCpltCallback:
bAudioIsStarted = awe_audioIsStarted(&g_AWEInstance);
bLayoutValid = awe_layoutIsValid(&g_AWEInstance);
if(bAudioIsStarted && bLayoutValid) {
ret = awe_audioImportSamples(&g_AWEInstance, (fract16 *) &send_to_AWE_buffer[0], STRIDE2, CHANNEL1, Sample16bit);
// if(ret==0) printf("success\n");
ret = awe_audioImportSamples(&g_AWEInstance, (fract16 *) &send_to_AWE_buffer[1], STRIDE2, CHANNEL2, Sample16bit);
// if(ret==0) printf("success\n");
ret = awe_audioExportSamples(&g_AWEInstance, (INT16 *) &receive_from_AWE_buffer[0], STRIDE2, CHANNEL1, Sample16bit);
// if(ret==0) printf("success\n");
ret = awe_audioExportSamples(&g_AWEInstance, (INT16 *) &receive_from_AWE_buffer[1], STRIDE2, CHANNEL2, Sample16bit);
// if(ret==0) printf("success\n");
}
Code executed for HAL_I2S_TxCpltCallback:
bAudioIsStarted = awe_audioIsStarted(&g_AWEInstance);
bLayoutValid = awe_layoutIsValid(&g_AWEInstance);
if(bAudioIsStarted && bLayoutValid) {
ret = awe_audioImportSamples(&g_AWEInstance, (fract16 *) &send_to_AWE_buffer[2*AUDIO_BLOCK_SIZE], STRIDE2, CHANNEL1, Sample16bit);
// if(ret==0) printf("success\n");
ret = awe_audioImportSamples(&g_AWEInstance, (fract16 *) &send_to_AWE_buffer[2*AUDIO_BLOCK_SIZE+1], STRIDE2, CHANNEL2, Sample16bit);
// if(ret==0) printf("success\n");
ret = awe_audioExportSamples(&g_AWEInstance, (INT16 *) &receive_from_AWE_buffer[2*AUDIO_BLOCK_SIZE], STRIDE2, CHANNEL1, Sample16bit);
// if(ret==0) printf("success\n");
ret = awe_audioExportSamples(&g_AWEInstance, (INT16 *) &receive_from_AWE_buffer[2*AUDIO_BLOCK_SIZE+1], STRIDE2, CHANNEL2, Sample16bit);
// if(ret==0) printf("success\n");
}
2:42pm
I discovered an important thing. I had been modelling my approach on code from AudioDriver.c (clipped here), but in https://w.dspconcepts.com/hubfs/Docs-AWECoreOS/AWECoreOS_UserGuide/a0006... I discovered the necessity for awe_audioPump(&g_AWEInstance, 0) between awe_audioImportSamples and awe_audioExportSamples. Getting output now.
11:18am
Thanks for the update!
Gary