# MIC_DoSamplingAsync

## Syntax

  `#include <nitro/spi.h>`

      MICResult MIC_DoSamplingAsync(
                  MICSamplingType  type,
                  void*            buf,
                  MICCallback      callback,
                  void*            arg );

## Arguments

type | Sampling type as one of the `MICSamplingType` enumerated types.
buf | Pointer to the buffer where the sampling result is stored.
callback | Pointer to the callback function. This callback is called from inside the interrupt handler.
arg | Argument to pass to the callback function.

## Return Values

Returns the processing result as a `MICResult` enumerated type. If the asynchronous process started normally, returns `MIC_RESULT_SUCCESS`. If the process fails for some reason, returns some other value.

## Description

Samples the microphone once asynchronously. Use the `PM_SetAmp*` function to turn on the programmable gain amp before sampling.
This function issues a request to ARM7 to execute sampling and returns to the invoking program without waiting for a response from the ARM7 processor. To get the result from the processor, you must use the result argument. Where the input volume exceeds the minimum or maximum value, the output data will be clamped. You can use the `PM_SetAmpGain*` functions in advance to adjust the input volume that can be sampled. If this function fails, no operation is performed, and no user callback function is called.

## Note

This function asynchronously writes values to the buffer specified by the buf argument. Do not attempt to use the buffer until you have confirmed the completion of asynchronous processes by the user callback function.

It has been confirmed that slight hardware noise is mixed with the microphone input on the TWL system. See here for a workaround.

## See Also

`MIC_DoSampling`
`PM_SetAmpGain*`

## Revision History

2009/06/25 Added description about using the `PM_SetAmp*` function.
2005/06/27 Added text indicating that the callback is called from the interrupt handler.
2005/01/11 Revised return value.
2004/08/10 Added description related to input volume.
2004/06/01 Initial version.

CONFIDENTIAL