View previous topic :: View next topic |
Author |
Message |
koll_kkc Guest
|
MT8888 CODE HELP |
Posted: Wed Sep 13, 2006 6:59 am |
|
|
I need a sample cod for use with MT8888.
Somebody can help me?
Thanks |
|
|
John Morley
Joined: 09 Aug 2004 Posts: 97
|
|
Posted: Wed Sep 13, 2006 3:22 pm |
|
|
Hi,
I've only worked with the MT8870 DTMF receiver, but this should give you a start.
Here are the codes that the DTMF receiver will generate:
Code: |
// MT8870 DTMF Decoder Output
//
// Digit Code
// 1 1
// 2 2
// 3 3
// 4 4
// 5 5
// 6 6
// 7 7
// 8 8
// 9 9
// 0 10
// * 11
// # 12
// A 13
// B 14
// C 15
// D 0
|
Here are some sample pin assignments for the DTMF data lines and DTMF strobe (valid) line:
Code: |
#define DTMF_Data1 PIN_A0
#define DTMF_Data2 PIN_A1
#define DTMF_Data3 PIN_A2
#define DTMF_Data4 PIN_A3
#define DTMF_STB PIN_B0
|
Here is some code to actually grab the DTMF tone:
Code: |
int DTMF_CMD;
if (input(DTMF_STB)) // wait for DTMF_STB to go hi...
{
DTMF_CMD= input(DTMF_Data1) + ( 2 * input(DTMF_Data2)) + (4 * input(DTMF_Data3)) + (8 * input(DTMF_Data4));
}
|
Writing a robust algorithm to receive strings of DTMF tones and validate them is not completely trivial because you have to allow for a user that holds a key for a long time, or waits too long between key presses, etc. This code will help to get you started actually receiving data. If you need help beyond this, let me know. _________________ John Morley |
|
|
Mark Weir
Joined: 11 Sep 2003 Posts: 51 Location: New Zealand
|
CM8870 |
Posted: Thu Sep 14, 2006 5:00 pm |
|
|
Hi John,
Could you please explain your code segement a little more fully. I have been using this device also and I grab the code like this
[#int_EXT
EXT_isr()
{ if (input(tone_pres))// Tone pres looks at pin15 cm8870
{
load_tone = input_d() & 0x0f ; // Read incoming tone
tone_flag = 1; }
}]
The four outputs are connected to portd, I just and out the unwanted bits, so I end up with a 4 bit word called load_tone that I can use in a switch.
I too am interested in the cm8889 transceiver but like our orinal poster am a bit unsure of where to start to build the driver. I managed to get thr receiver only working quite well.
Cheers
Mark
[/code] |
|
|
John Morley
Joined: 09 Aug 2004 Posts: 97
|
|
Posted: Mon Sep 18, 2006 7:37 pm |
|
|
Mark,
I "poll" the data valid line from the MT8870 because I don't have any other processes going on. Your technique of using the external interrupt looks OK too. Your method of grabbing the digits also looks fine to me. Does it work as you expect? The possible values for the received tones are shown in the table in my original post.
Sorry, I don't have any transmit code, but it would be easy to put the desired output tone code on some output pins and strobe the "send" line - very nearly the reverse of receiving DTMF data!
Have you got the receive code to store the incoming tones and to put them into an array for validation and processing?
John _________________ John Morley |
|
|
Mark Weir
Joined: 11 Sep 2003 Posts: 51 Location: New Zealand
|
MT8870 |
Posted: Mon Sep 18, 2006 8:06 pm |
|
|
Hi John,
Have you got the receive code to store the incoming tones and to put them into an array for validation and processing?
At the moment I am storing each digit into a separate int, I capture 4 digits for the application. I have been getting away with this so far but I can't honsestly say it's bulletproof. I am interested in knowing how you would use an array as I have not had any experience using them so far and think this would be a better way to validate what was sent. |
|
|
|