programming of 8880 with LPC2148

Discussion in 'Programmer's Corner' started by tejal, Feb 10, 2010.

  1. tejal

    Thread Starter New Member

    Feb 10, 2010
    1
    0
    Hello, We r interfacing 8880 to LPC2148. But not getting dialing tone. The code as shown below. Pls guide us.

    // Dialling phone number

    #include <Philips\LPC2148.h>
    #include <stdio.h>
    #include <ctype.h>
    #include <stdlib.h>
    #include <string.h>

    char buffer[33];
    int s;

    #define Relay 1

    #define CS_Dial 30
    #define RW_Dial 25
    #define RS_Dial 29

    #define D0 4
    #define D1 5
    #define D2 6
    #define D3 21
    /**************************************************************************************/
    void delay(int counter)
    {
    while(--counter);
    }
    /**************************************************************************************/
    void Set_Control(void)
    {
    IO1SET |= (1<<D3);
    IO0CLR |= (1<<D2);
    IO0SET |= (1<<D1);
    IO0SET |= (1<<D0);
    IO0SET |= (1<<RS_Dial);
    IO0CLR |= (1<<RW_Dial);
    IO0CLR |= (1<<CS_Dial);

    IO0SET |= (1<<CS_Dial);

    delay(1200);

    IO1CLR |= (1<<D3);
    IO0CLR |= (1<<D2);
    IO0CLR |= (1<<D1);
    IO0CLR |= (1<<D0);
    IO0SET |= (1<<RS_Dial);
    IO0CLR |= (1<<RW_Dial);
    IO0CLR |= (1<<CS_Dial);

    IO0SET |= (1<<CS_Dial);

    delay(1200);
    }
    void init_dial(void)
    {
    IO0SET |= (1<<CS_Dial);
    IO0SET |= (1<<RW_Dial);
    IO0SET |= (1<<RS_Dial);
    IO0SET |= (1<<D0);
    IO0SET |= (1<<D1);
    IO0SET |= (1<<D2);
    IO1SET |= (1<<D3);

    IO0CLR |= (1<<Relay);

    IO0DIR |= (1<<CS_Dial);
    IO0DIR |= (1<<RW_Dial);
    IO0DIR |= (1<<RS_Dial);
    IO0DIR |= (1<<Relay);

    IO0DIR |= (1<<D0);
    IO0DIR |= (1<<D1);
    IO0DIR |= (1<<D2);
    IO1DIR |= (1<<D3);

    delay(2000);

    IO0SET |= (1<<CS_Dial);
    IO0SET |= (1<<RW_Dial);
    IO0SET |= (1<<RS_Dial);
    IO0SET |= (1<<D0);
    IO0SET |= (1<<D1);
    IO0SET |= (1<<D2);
    IO1SET |= (1<<D3);

    IO0CLR |= (1<<Relay);

    delay(2000);
    }

    /***************************************************************************************/
    //dials a number
    /***************************************************************************************/
    void Dial_Digit(void)
    {
    switch ( s )
    {
    case 0x00:
    IO1SET |= (1<<D3);
    IO0CLR |= (1<<D2);
    IO0SET |= (1<<D1);
    IO0CLR |= (1<<D0);
    break;
    case 0x01:
    IO1CLR |= (1<<D3);
    IO0CLR |= (1<<D2);
    IO0CLR |= (1<<D1);
    IO0SET |= (1<<D0);
    break;
    case 0x02:
    IO1CLR |= (1<<D3);
    IO0CLR |= (1<<D2);
    IO0SET |= (1<<D1);
    IO0CLR |= (1<<D0);
    break;
    case 0x03:
    IO1CLR |= (1<<D3);
    IO0CLR |= (1<<D2);
    IO0SET |= (1<<D1);
    IO0SET |= (1<<D0);
    break;
    case 0x04:
    IO1CLR |= (1<<D3);
    IO0SET |= (1<<D2);
    IO0CLR |= (1<<D1);
    IO0CLR |= (1<<D0);
    break;
    case 0x05:
    IO1CLR |= (1<<D3);
    IO0SET |= (1<<D2);
    IO0CLR |= (1<<D1);
    IO0SET |= (1<<D0);
    break;
    case 0x06:
    IO1CLR |= (1<<D3);
    IO0SET |= (1<<D2);
    IO0SET |= (1<<D1);
    IO0CLR |= (1<<D0);
    break;
    case 0x07:
    IO1CLR |= (1<<D3);
    IO0SET |= (1<<D2);
    IO0SET |= (1<<D1);
    IO0SET |= (1<<D0);
    break;
    case 0x08:
    IO1SET |= (1<<D3);
    IO0CLR |= (1<<D2);
    IO0CLR |= (1<<D1);
    IO0CLR |= (1<<D0);
    break;
    case 0x09:
    IO1SET |= (1<<D3);
    IO0CLR |= (1<<D2);
    IO0CLR |= (1<<D1);
    IO0SET |= (1<<D0);
    break;
    case 0x0b:
    IO0SET |= (1<<D0);
    IO0SET |= (1<<D1);
    IO0CLR |= (1<<D2);
    IO1SET |= (1<<D3);
    break;
    case 0x0c:
    IO0CLR |= (1<<D0);
    IO0CLR |= (1<<D1);
    IO0SET |= (1<<D2);
    IO1SET |= (1<<D3);
    break;
    }
    IO0CLR |= (1<<RS_Dial);
    IO0CLR |= (1<<RW_Dial);
    IO0CLR |= (1<<CS_Dial);

    IO0SET |= (1<<CS_Dial);

    delay(2000);
    }

    void Dial( void )
    {
    unsigned char ii = 0;

    IO0CLR |= (1<<Relay);
    delay(40000);

    IO0SET |= (1<<Relay);

    delay(50000);

    sprintf(buffer,"%s","9427892501* ");

    while ( buffer[ii] != '*')
    {
    s = buffer[ii] - '0';
    Dial_Digit();

    RC1 = 0;

    while(RC1 == 0)
    {
    IO0DIR &= (~(1<<D0));
    IO0DIR &= (~(1<<D1));
    IO0DIR &= (~(1<<D2));
    IO1DIR &= (~(1<<D3));

    delay(20000);

    Get_Status();
    RC1 = (RC1>>1);
    RC1 &= 0x01;
    }
    ii++;

    IO0DIR |= (1<<D0);
    IO0DIR |= (1<<D1);
    IO0DIR |= (1<<D2);
    IO1DIR |= (1<<D3);

    delay(2000);
    }
    for(ii=0;ii<100;ii++)
    {
    delay (50000);
    } //delay for giving ring to Tel.no.

    IO0CLR |= (1<<Relay);
    }
    /***************************************************************************************/
    //####################### Main Fuction ###############################################
    /***************************************************************************************/

    int main (void)
    {
    int i;

    init_dial();

    Set_Control();

    delay(2000000);
    Dial();

    while(1);
    return 0;
    }
     
Loading...