Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/29/03 14:28
Read: times


 
#46911 - RE: About Cprogramming the DTMF chip MT8
Responding to: ???'s previous message
I have written some ASM routines for the MT8888 that can be called from C. It shouldn't be difficult to re-write them in C if you want. In this system, D1-D4 of the chip are connected to P0.0-P0.3

RD_      EQU P0.4          ; !RD line for the DTMF transceiver (active low)
WR_      EQU P0.5          ; !WR line for the DTMF transceiver (active low)
CS_DTMF  EQU P0.6          ; !CS line for the DTMF transceiver (active low)
RS_0     EQU P3.7          ; Register Select line of the DTMF transceiver


_WRITE_CREG:
  MOV    A,R7              ; Get the data to be written
  ORL    A,#0F0h           ; Mask the high nibble so that the control line are not affected
  MOV    P0,A              ; 
  SETB   RS_0              ; Set the Register Select line to select the Control Register
  CLR    CS_DTMF           ; Select the transceiver
  CLR    WR_               ; Pulse the WR line low
  SETB   WR_
  SETB   CS_DTMF           ; Set the Chip Select high
  RET
  
  
_WRITE_TREG:
  MOV    A,R7              ; Get the data to be written
  ORL    A,#0F0h           ; Mask the high nibble so that the control line are not affected 
  MOV    P0,A              ; 
  CLR    RS_0              ; Clear the Register Select line to select the Transmit Register
  CLR    CS_DTMF           ; Select the transceiver
  CLR    WR_               ; Pulse the WR line low
  SETB   WR_
  SETB   CS_DTMF           ; Set the Chip Select high
  RET
  
READ_CREG:
  MOV    P0,#0FFh          ; Setup P0 for input
  SETB   RS_0              ; Set the Register Select line to select the Control Register
  CLR    CS_DTMF           ; Select the transceiver
  CLR    RD_               ; Clear the RD line
  MOV    A,P0              ; Get the data
  SETB   RD_               ; Deactivate the RD
  SETB   CS_DTMF           ; Deselect the transceiver
  ANL    A,#0Fh            ; Mask off the high nibble
  MOV    R7,A              ; Copy the data to R7 for C compatibility
  RET
  
READ_RREG:
  MOV    P0,#0FFh          ; Setup P0 for input
  CLR    RS_0              ; Clear the Register Select line to select the Receive Register
  CLR    CS_DTMF           ; Select the transceiver
  CLR    RD_               ; Clear the RD line
  MOV    A,P0              ; Get the data
  SETB   RD_               ; Deactivate the RD
  SETB   CS_DTMF           ; Deselect the transceiver
  ANL    A,#0Fh            ; Mask off the high nibble
  MOV    R7,A              ; Copy the data to R7 for C compatibility
  RET


In the C code these routines are declared as follows:
extern void Write_Creg(char control_char);
extern void Write_Treg(char transmit_char);
extern char Read_Creg(void);
extern char Read_Rreg(void);


Initialisation of the MT8888 in accordance with the datasheet:
Read_Creg();           // Initialise the DTMF transceiver
Write_Creg(0);
Write_Creg(0);
Write_Creg(8);
Write_Creg(0);
Read_Creg();


And finally generating a tone.
void Tone(char type_of_tone) {
  switch (type_of_tone) {
  case '0':
    Write_Treg(10);
    break;
  case '*':
    Write_Treg(11);
    break;
  case '#':
    Write_Treg(12);
    break;
  case 'D':
    Write_Treg(0);
    break;
  default:
    if (type_of_tone >= '1' && type_of_tone <= '9')
      Write_Treg(type_of_tone - 48);
    else
      Write_Treg(type_of_tone - 52);
  }
  Write_Creg(1);                                      // Tone on
  Delay(65);
  Write_Creg(0);                                      // Tone off
  Delay(65);
}


That should get you started, I think...

Best regards,
Rob.

List of 10 messages in thread
TopicAuthorDate
About Cprogramming the DTMF chip MT8888            01/01/70 00:00      
   RE: About Cprogramming the DTMF chip MT8            01/01/70 00:00      
      RE: About Cprogramming the DTMF chip MT8            01/01/70 00:00      
   RE: About Cprogramming the DTMF chip MT8888            01/01/70 00:00      
      RE: About Cprogramming the DTMF chip MT8            01/01/70 00:00      
   RE: About Cprogramming the DTMF chip MT8888            01/01/70 00:00      
      RE: About Cprogramming the DTMF chip MT8888            01/01/70 00:00      
      RE: About Cprogramming the DTMF chip MT8            01/01/70 00:00      
         RE: About Cprogramming the DTMF chip MT8            01/01/70 00:00      
            RE: About Cprogramming the DTMF chip MT8            01/01/70 00:00      

Back to Subject List