
Dual Tone Multi-Frequency (DTMF) Receiver for VS1003

This solution decodes incoming DTMF signals to digits 0-9, A-D and #,*. 

DTMF Keyboard configuration:

-		High Frequency Group Index
-		0: 1209Hz	1: 1336Hz	2: 1477Hz	3: 1633Hz
-		0: 697Hz	1		2		3		A
Low				
Freq.	1: 770Hz	4		5		6		B
Group
Index	2: 852Hz	7		8		9		C
-				
-		3: 941Hz	*		0		#		D
-

DTMF Keyboard configuration (shown in alternative format):
Low Freq. Group Idx    0, High Freq. Group Idx    0 = Key 1
Low Freq. Group Idx    0, High Freq. Group Idx    1 = Key 2
Low Freq. Group Idx    0, High Freq. Group Idx    2 = Key 3
Low Freq. Group Idx    0, High Freq. Group Idx    3 = Key A
Low Freq. Group Idx    1, High Freq. Group Idx    0 = Key 4
Low Freq. Group Idx    1, High Freq. Group Idx    1 = Key 5
Low Freq. Group Idx    1, High Freq. Group Idx    2 = Key 6
Low Freq. Group Idx    1, High Freq. Group Idx    3 = Key B
Low Freq. Group Idx    2, High Freq. Group Idx    0 = Key 7
Low Freq. Group Idx    2, High Freq. Group Idx    1 = Key 8
Low Freq. Group Idx    2, High Freq. Group Idx    2 = Key 9
Low Freq. Group Idx    2, High Freq. Group Idx    3 = Key C
Low Freq. Group Idx    3, High Freq. Group Idx    0 = Key *
Low Freq. Group Idx    3, High Freq. Group Idx    1 = Key 0
Low Freq. Group Idx    3, High Freq. Group Idx    2 = Key #
Low Freq. Group Idx    3, High Freq. Group Idx    3 = Key D
Low Freq. Group Idx 0xFF, High Freq. Group Idx 0xFF = Key unpressed

Operation:
Solution generates message that can be read through the SCI bus when valid
digit is received or cleared. Received digits are stored in 63 digit
ringbuffer readable on SCI bus.

For example, when system starts receiving frequencies 770Hz and 1633Hz, digit
"B" is received with SCI message generated for low frequency index 1 (row)
and high frequency index 3 (column). When signal ends (button is released)
message with low and high frequency group indexes both at value 0xff is
generated.

Audio signal input is line-in.





SCI Digit Message format:
Message on SCI bus consists of 8 16-bit words.
1.word: Running number of message
2.word: High 16 bits of 32-bit upcounting timestamp
	(divider 256, resulting f=48kHz)
3.word: Low 16 bits of 32-bit upcounting timestamp
4.word: Low frequency group index [0-3] for digit row or 0xff for digit
	cleared (see Keyboard configuration)
5.word: High frequency group index [0-3] for digit column or 0xff for digit
	cleared (see Keyboard configuration)
6-8.:	Reserved.

Procedure for reading SCI digit messages
{
	int i;
	// Get number of messages available from register SC_IN1
	int messages = ReadSCI(SCI_IN1) >> 3);
	
	// Read and handle all messages
	for (i = 0; i < messages; i++) {
		int j;
		u_int16 messageWord[8];		
		// each message has 8 words
		for (j = 0; j < 8; j++) {
			// Read message data from register SCI_IN0
			int messageWord[j] = ReadSCI(SCI_IN0);
		}
		// Handle message
		// ...
	}
}


Customization:
Digit recogcnition condition (DRC) can be adjusted by selecting suitable
P_UPPER and P_LOWER from precalculated #defines. P_UPPER sets highest
acceptaple level for digit. Values are provided  [-5dBV, -2dBV],
-5dBV being most strict setting. P_LOWER sets minimum level and
precalculated values are [-27dBV, -34dBV], where -27dBV is most strict.
