Is there an example for enabling the HWVAD on the RT117x? I see the API in the PDM driver, but I'm unable to get an interrupt to fire using the recommended settings defined in fsl_pdm.h. Assuming the clocks and channels are already configured (I can capture properly with PDM EDMA transfer) My thought was something like this:
void AudioTask::HandleEnableVoiceDetection(SetCallbackRequest& set_callback) {
const pdm_hwvad_config_t hwvadConfig = {
.channel = 0,
.initializeTime = 10U,
.cicOverSampleRate = 0U,
.inputGain = 0U,
.frameTime = 10U,
.cutOffFreq = kPDM_HwvadHpfBypassed,
.enableFrameEnergy = false,
.enablePreFilter = true,
};
const pdm_hwvad_noise_filter_t noiseFilterConfig = {
.enableAutoNoiseFilter = false,
.enableNoiseMin = true,
.enableNoiseDecimation = true,
.enableNoiseDetectOR = true,
.noiseFilterAdjustment = 0U,
.noiseGain = 7U,
};
PDM_SetHwvadInEnvelopeBasedMode(PDM, &hwvadConfig, &noiseFilterConfig, nullptr, 0);
PDM_EnableHwvadInterrupts(PDM, kPDM_HwvadInterruptEnable | kPDM_HwvadErrorInterruptEnable);
voice_callback_ = set_callback.callback;
voice_callback_param_ = set_callback.callback_param;
}
This seems to match what the reference manual says looking into the SetHwvadInEnvelopeBasedMode function. Am I missing something obvious? Is there a driver example of this in action?
Thanks,
Michael
HI Michael,
I guess the issue is with signalGain (VADSGAIN in VAD0_SCONFIG register) value passed as last parameter to API PDM_SetHwvadInEnvelopeBasedMode. I think you are passing a value of 0 which is gain value of 1 and you have used a noisegain (VADNGAIN in VAD0_NCONFIG register) value of 7 inside structure noiseFilterConfig .
According to RM:
56.3.6.7.5 Filter Result Gain Setting
There are two gain adjustment controls, one for the estimated noise (VADNGAIN) and
another for signal estimated (VADSGAIN). Both gain adjustments outputs are compared,
the comparison result determines whether or not there is voice in the channel.
I extended the pdm_sai_edma SDK example to add your below code and also added code to enable IRQ for HWVAD and get IRQ handler callback at application level. As soon as, I changed signalGain parameter to a value greater than or equal to noisegain (7), I was able to hit breakpoint in my IRQ handler for HWVAD. I also checked that if I reduce the value for noisegain , I could achieve the same results. Can you please try to change the value and see if you are still getting this issue?
@jingpan Can you please confirm from R&D , if there is any recommendation against VADSGAIN in VAD0_SCONFIG register and VADNGAIN in VAD0_NCONFIG register?
Regards,
Shweta
@shweta_chauhan : Thanks - this is great insight. I haven't been able to get an interrupt to fire in my application code, but I'm working on porting the pdm_sai_edma example to our board. Can you provide a patch of the changes you made to get the HWVAD working in this example?
@jingpan : Please let me know if the R&D has recommendations on gain settings. It would seem that N+1 is probably not enough to properly gauge signal vs noise, but this is likely application specific.
Thanks!
Hi,
PFA the pdm_sai_edma.c file here which was modified for adding HWVAD related changes, this is the only file changed w.r.t pdm_sai_edma SDK example.
Note that the values in actual product will differ based on the usecase and this code was used just to check API and to see if application can receive HWVAD interrupt or not.
Regards,
Shweta