HWVAD Example for RT1170

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HWVAD Example for RT1170

1,586 Views
mrbrooks
Contributor II

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

 

0 Kudos
6 Replies

1,509 Views
shweta_chauhan
NXP Employee
NXP Employee

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

 

 

0 Kudos

1,460 Views
mrbrooks
Contributor II

@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!

0 Kudos

1,455 Views
shweta_chauhan
NXP Employee
NXP Employee

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

0 Kudos

1,055 Views
Burjak
Contributor III
Hello,
can you please tell, how the noise filter from HWVAD affects PDM? Can it reduce background noise on recording sound?
I tried your file with different settings of noiseFilterConfig but I guess HWVAD just not worked for me.
Thanks
0 Kudos

1,477 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @shweta_chauhan ,

Yes my testing result is same with yours. 

 

Regards,

Jing

0 Kudos

1,547 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @mrbrooks ,

I've asked to SDK team. I'll let you know as soon as I get answer.

 

Regards,

Jing

0 Kudos