# Detecting DTMF tones

When a station is off-hook, the DSP can detect DTMF tones and return their values to the application. This topic describes:

- Starting DTMF detection

- Stopping DTMF detection

## Starting DTMF detection

To start DTMF detection, invoke cdiStartDTMFDetector. In the invocation, pass a pointer to the CDI_DTMFDETECTOR_PARMS structure. If detection is started successfully, cdiStartDTMFDetector returns SUCCESS.

CDIEVN_DTMF_STARTED is generated for each detected tone. The event value field contains the ASCII representation of the key. When the tone ends, CDIEVN_DTMF_ENDED is generated.

If cdiStartDTMFDetector is invoked when the DSP does not have enough MIPS to satisfy the request, CTAERR_OUT_OF_RESOURCES is returned.

## Stopping DTMF detection

If enhanced mode is enabled, the DSP automatically stops DTMF detection for a station when the station goes on-hook (CDIEVN_ON_HOOK is returned). If enhanced mode is disabled, the application can invoke cdiStopDTMFDetector to stop detection.

If the station is on-hook, and cdiStopDTMFDetector is invoked, CTAERR_FUNCTION_NOT_ACTIVE is returned.