اطلاعیه

Collapse
No announcement yet.

اینم سورس برنامه من با mt8870که ic dtmf است و با CodeVisionAVR C Compiler نوشتم

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    اینم سورس برنامه من با mt8870که ic dtmf است و با CodeVisionAVR C Compiler نوشتم

    #include <delay.h>


    #include <Stdlib.h>

    #include <mega16.h>

    // Alphanumeric LCD Module functions
    #asm
    .equ __lcd_port=0x15
    #endasm
    #include <lcd.h>

    // Declare your global variables here
    char st[10];
    int i=0,a,b,c,d,k,l,m,e;
    eeprom int j=3211 ;

    void main(void)
    {
    // Declare your local variables here

    // Input/Output Ports initialization
    // Port A initialization
    // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In
    // State0=T State1=T State2=T State3=T State4=T State5=T State6=T State7=T
    PORTA=0x00;
    DDRA=0x00;

    // Port B initialization
    // Func0=Out Func1=Out Func2=Out Func3=Out Func4=Out Func5=Out Func6=Out Func7=Out
    // State0=0 State1=0 State2=0 State3=0 State4=0 State5=0 State6=0 State7=0
    PORTB=0x00;
    DDRB=0xFF;

    // Port C initialization
    // Func0=In Func1=In Func2=In Func3=In Func4=In Func5=In Func6=In Func7=In
    // State0=T State1=T State2=T State3=T State4=T State5=T State6=T State7=T
    PORTC=0x00;
    DDRC=0x00;

    // Port D initialization
    // Func0=In Func1=In Func2=In Func3=In Func4=Out Func5=Out Func6=In Func7=In
    // State0=T State1=T State2=T State3=T State4=0 State5=0 State6=T State7=T
    PORTD=0x00;
    DDRD=0x30;

    // Timer/Counter 0 initialization
    // Clock source: System Clock
    // Clock value: Timer 0 Stopped
    // Mode: Normal top=FFh
    // OC0 output: Disconnected
    TCCR0=0x00;
    TCNT0=0x00;
    OCR0=0x00;
    // Timer/Counter 1 initialization
    // Clock source: System Clock
    // Clock value: Timer 1 Stopped
    // Mode: Normal top=FFFFh
    // OC2 output: Disconnected
    TCCR1A=0x00;
    TCCR1B=0x00;
    TCNT1H=0x00;
    TCNT1L=0x00;
    OCR1AH=0x00;
    OCR1AL=0x00;
    OCR1BH=0x00;
    OCR1BL=0x00;
    // Timer/Counter 2 initialization
    // Clock source: System Clock
    // Clock value: Timer 2 Stopped
    // Mode: Normal top=FFh
    // OC2 output: Disconnected
    ASSR=0x00;
    TCCR2=0x00;
    TCNT2=0x00;
    OCR2=0x00;

    // External Interrupt(s) initialization
    // INT0: Off
    // INT1: Off
    // INT2: Off
    GICR|=0x00;
    MCUCR=0x00;
    MCUCSR=0x00;

    // Timer(s)/Counter(s) Interrupt(s) initialization
    TIMSK=0x00;

    // Analog Comparator initialization
    // Analog Comparator: Off
    // Analog Comparator Input Capture by Timer/Counter 1: Off
    // Analog Comparator Output: Off
    ACSR=0x80;
    SFIOR=0x00;

    // LCD module initialization
    lcd_init(16);

    while (1)

    {

    a=j%10;
    b=((j-a)%100)/10;
    c=(((j%1000)-(10*b+a))/100);
    d=(((j%10000)-(100*c+10*b+a))/1000);
    lcd_clear();
    PORTB=0b00000000;
    delay_ms(1000);
    PORTB=0b11111111;
    delay_ms(1000);
    PORTB=0b00000000;
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("inTheNameOfGod"
    delay_ms(4600);
    lcd_gotoxy(0,1); //desimal
    lcd_putsf("ATMEGA 16/MT8870 "
    delay_ms(5600);
    lcd_gotoxy(0,1); //desimal
    lcd_putsf("codevision AVR C "
    delay_ms(5600);
    lcd_gotoxy(0,1); //desimal
    lcd_putsf("ST:m.Ghorbanali "
    delay_ms(5600);
    lcd_gotoxy(0,1); //desimal
    lcd_putsf("THRAN JNUB UNIT "
    delay_ms(5600);


    lcd_clear();
    ali:
    if (PIND.6==0)// zang ditect
    {
    PORTB=0b00000000;
    delay_ms(500);
    PORTB=0b11111111;
    delay_ms(1550);
    lcd_gotoxy(1,0);
    lcd_putsf("sallam:"
    PORTD.5=1; // relay
    delay_ms(1000);
    }
    else
    {
    goto ali;
    }
    i=3,k=2,l=1,m==1;
    lcd_clear();
    lcd_clear();
    e=0;

    //************************************************** *******************************************
    mohsen1:
    if (PIND.7==1)// ton resived
    {

    delay_ms(100);
    if (PIND.3==1 & PIND.2==0 & PIND.1==0 & PIND.0==0 )
    {
    i=1;
    }
    if (PIND.3==0 & PIND.2==1 & PIND.1==0 & PIND.0==0)
    {
    i=2;
    }
    if (PIND.3==1 & PIND.2==1 & PIND.1==0 & PIND.0==0 )
    {
    i=3;
    }
    if (PIND.3==0 & PIND.2==0 & PIND.1==1 & PIND.0==0 )
    {
    i=4;
    }
    if ( PIND.3==1 & PIND.2==0 & PIND.1==1 & PIND.0==0 )
    {
    i=5;
    }
    if ( PIND.3==0 & PIND.2==1 & PIND.1==1 & PIND.0==0 )
    {
    i=6;
    }
    if ( PIND.3==1 & PIND.2==1 & PIND.1==1 & PIND.0== 0 )
    {
    i=7;
    }
    if ( PIND.3==0 & PIND.2==0 & PIND.1==0 & PIND.0==1 )
    {
    i=8;
    }
    if ( PIND.3==1 & PIND.2==0 & PIND.1==0 & PIND.0==1 )
    {
    i=9;
    }
    if ( PIND.3==0 & PIND.2==1 & PIND.1==0 & PIND.0==1 )

    i=0;

    if ( PIND.3==1 & PIND.2==1 & PIND.1==0 & PIND.0==1 )
    {
    i=11;
    }
    if ( PIND.3==0 & PIND.2==0 & PIND.1==1 & PIND.0==1 )
    {
    i=12;
    }
    }
    else
    {
    goto mohsen1;

    }
    delay_ms(1000);
    //************************************************** *******************************************
    //************************************************** *******************************************
    mohsen2:
    if (PIND.7==1)// ton resived
    {

    if (PIND.3==1 & PIND.2==0 & PIND.1==0 & PIND.0==0 )
    {
    k=1;
    }
    if (PIND.3==0 & PIND.2==1 & PIND.1==0 & PIND.0==0)
    {
    k=2;
    }
    if (PIND.3==1 & PIND.2==1 & PIND.1==0 & PIND.0==0 )
    {
    k=3;
    }
    if (PIND.3==0 & PIND.2==0 & PIND.1==1 & PIND.0==0 )
    {
    k=4;
    }
    if ( PIND.3==1 & PIND.2==0 & PIND.1==1 & PIND.0==0 )
    {
    k=5;
    }
    if ( PIND.3==0 & PIND.2==1 & PIND.1==1 & PIND.0==0 )
    {
    k=6;
    }
    if ( PIND.3==1 & PIND.2==1 & PIND.1==1 & PIND.0== 0 )
    {
    k=7;
    }
    if ( PIND.3==0 & PIND.2==0 & PIND.1==0 & PIND.0==1 )
    {
    k=8;
    }
    if ( PIND.3==1 & PIND.2==0 & PIND.1==0 & PIND.0==1 )
    {
    k=9;
    }
    if ( PIND.3==0 & PIND.2==1 & PIND.1==0 & PIND.0==1 )

    k=0;

    if ( PIND.3==1 & PIND.2==1 & PIND.1==0 & PIND.0==1 )
    {
    k=11;
    }
    if ( PIND.3==0 & PIND.2==0 & PIND.1==1 & PIND.0==1 )
    {
    k=12;
    }
    }
    else
    {
    goto mohsen2;

    }
    delay_ms(1000);
    //************************************************** *******************************************
    //************************************************** *******************************************
    mohsen3:
    if (PIND.7==1)// ton resived
    {

    if (PIND.3==1 & PIND.2==0 & PIND.1==0 & PIND.0==0 )
    {
    l=1;
    }
    if (PIND.3==0 & PIND.2==1 & PIND.1==0 & PIND.0==0)
    {
    l=2;
    }
    if (PIND.3==1 & PIND.2==1 & PIND.1==0 & PIND.0==0 )
    {
    l=3;
    }
    if (PIND.3==0 & PIND.2==0 & PIND.1==1 & PIND.0==0 )
    {
    l=4;
    }
    if ( PIND.3==1 & PIND.2==0 & PIND.1==1 & PIND.0==0 )
    {
    l=5;
    }
    if ( PIND.3==0 & PIND.2==1 & PIND.1==1 & PIND.0==0 )
    {
    l=6;
    }
    if ( PIND.3==1 & PIND.2==1 & PIND.1==1 & PIND.0== 0 )
    {
    l=7;
    }
    if ( PIND.3==0 & PIND.2==0 & PIND.1==0 & PIND.0==1 )
    {
    l=8;
    }
    if ( PIND.3==1 & PIND.2==0 & PIND.1==0 & PIND.0==1 )
    {
    l=9;
    }
    if ( PIND.3==0 & PIND.2==1 & PIND.1==0 & PIND.0==1 )

    l=0;

    if ( PIND.3==1 & PIND.2==1 & PIND.1==0 & PIND.0==1 )
    {
    l=11;
    }
    if ( PIND.3==0 & PIND.2==0 & PIND.1==1 & PIND.0==1 )
    {
    l=12;
    }
    }
    else
    {
    goto mohsen3;

    }
    delay_ms(1000);
    //************************************************** **********************************************
    //************************************************** *******************************************
    mohsen4:
    if (PIND.7==1)// ton resived
    {

    if (PIND.3==1 & PIND.2==0 & PIND.1==0 & PIND.0==0 )
    {
    m=1;
    }
    if (PIND.3==0 & PIND.2==1 & PIND.1==0 & PIND.0==0)
    {
    m=2;
    }
    if (PIND.3==1 & PIND.2==1 & PIND.1==0 & PIND.0==0 )
    {
    m=3;
    }
    if (PIND.3==0 & PIND.2==0 & PIND.1==1 & PIND.0==0 )
    {
    m=4;
    }
    if ( PIND.3==1 & PIND.2==0 & PIND.1==1 & PIND.0==0 )
    {
    m=5;
    }
    if ( PIND.3==0 & PIND.2==1 & PIND.1==1 & PIND.0==0 )
    {
    m=6;
    }
    if ( PIND.3==1 & PIND.2==1 & PIND.1==1 & PIND.0== 0 )
    {
    m=7;
    }
    if ( PIND.3==0 & PIND.2==0 & PIND.1==0 & PIND.0==1 )
    {
    m=8;
    }
    if ( PIND.3==1 & PIND.2==0 & PIND.1==0 & PIND.0==1 )
    {
    m=9;
    }
    if ( PIND.3==0 & PIND.2==1 & PIND.1==0 & PIND.0==1 )

    m=0;

    if ( PIND.3==1 & PIND.2==1 & PIND.1==0 & PIND.0==1 )
    {
    m=11;
    }
    if ( PIND.3==0 & PIND.2==0 & PIND.1==1 & PIND.0==1 )
    {
    m=12;
    }
    }
    else
    {
    goto mohsen4;
    }

    //************************************************** ****************************
    // if ( i==d & k==c & l==b & m==a )
    if ( i==3 & k==2 & l==1 & m==1 )
    {
    j=3211;
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("welcom:"
    lcd_gotoxy(0,1);
    lcd_puts(st);
    itoa (j,st);
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("welcom:"
    lcd_gotoxy(5,1);
    lcd_puts(st);
    delay_ms(2000);
    //************************************************** ****************************
    mohsen6:
    delay_ms(800);
    lcd_clear();
    if (PIND.7==1)// ton resived

    {


    if (PIND.3==1 & PIND.2==0 & PIND.1==0 & PIND.0==0 )
    {
    i=1;
    }
    if (PIND.3==0 & PIND.2==1 & PIND.1==0 & PIND.0==0)
    {
    i=2;
    }
    if (PIND.3==1 & PIND.2==1 & PIND.1==0 & PIND.0==0 )
    {
    i=3;
    }
    if (PIND.3==0 & PIND.2==0 & PIND.1==1 & PIND.0==0 )
    {
    i=4;
    }
    if ( PIND.3==1 & PIND.2==0 & PIND.1==1 & PIND.0==0 )
    {
    i=5;
    }
    if ( PIND.3==0 & PIND.2==1 & PIND.1==1 & PIND.0==0 )
    {
    i=6;
    }
    if ( PIND.3==1 & PIND.2==1 & PIND.1==1 & PIND.0== 0 )
    {
    i=7;
    }
    if ( PIND.3==0 & PIND.2==0 & PIND.1==0 & PIND.0==1 )
    {
    i=8;
    }
    if ( PIND.3==1 & PIND.2==0 & PIND.1==0 & PIND.0==1 )
    {
    i=9;
    }
    if ( PIND.3==0 & PIND.2==1 & PIND.1==0 & PIND.0==1 )

    i=0;
    if ( PIND.3==1 & PIND.2==1 & PIND.1==0 & PIND.0==1 )
    {
    i=11;
    }
    if ( PIND.3==0 & PIND.2==0 & PIND.1==1 & PIND.0==1 )
    {
    i=12;
    }

    //************************************************** ****************************i give
    if ( i==1)
    {
    itoa (i,st);
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("relay1 is on:"
    lcd_gotoxy(5,1);
    lcd_puts(st);
    delay_ms(500);
    }
    if ( i==2)
    {
    itoa (i,st);
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("relay1 is off:"
    lcd_gotoxy(5,1);
    lcd_puts(st);
    delay_ms(500);
    }
    if ( i==3)
    {
    itoa (i,st);
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("relay2 is on:"
    lcd_gotoxy(5,1);
    lcd_puts(st);
    delay_ms(500);
    }
    if ( i==4)
    {
    itoa (i,st);
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("relay2 is off:"
    lcd_gotoxy(5,1);
    lcd_puts(st);
    delay_ms(500);
    }
    if ( i==5)
    {
    itoa (i,st);
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("relay3 is on:"
    lcd_gotoxy(5,1);
    lcd_puts(st);
    delay_ms(500);
    }
    if ( i==6)
    {
    itoa (i,st);
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("relay3 is off:"
    lcd_gotoxy(5,1);
    lcd_puts(st);
    delay_ms(500);
    }
    if ( i==7)
    {
    itoa (i,st);
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("relay4 is on:"
    lcd_gotoxy(5,1);
    lcd_puts(st);
    delay_ms(500);
    }
    if ( i==8)
    {
    itoa (i,st);
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("relay4 is off:"
    lcd_gotoxy(5,1);
    lcd_puts(st);
    delay_ms(500);
    }
    if ( i==9)
    {
    itoa (i,st);
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("relay5 is on:"
    lcd_gotoxy(5,1);
    lcd_puts(st);
    delay_ms(500);
    }
    if ( i==0)
    {
    itoa (i,st);
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("relay5 is off:"
    lcd_gotoxy(5,1);
    lcd_puts(st);
    delay_ms(500);
    }
    delay_ms(800);
    //***********************************************bay bay
    e=0;
    for (e=0;e<255;e++)
    {
    if (PIND.7==1)// ton resived
    {
    goto mohsen6;

    }
    delay_ms(100);

    }

    lcd_clear();
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("good bay"
    PORTD.5=0; // relay
    delay_ms(1000);
    goto ali;
    //***********************************************bay bay
    }
    else
    {
    goto mohsen6;

    }
    }
    else
    {
    PORTD.5=0; // relay
    lcd_gotoxy(0,0); //desimal
    lcd_putsf("no no!!!:"
    lcd_gotoxy(5,1);
    lcd_puts(st);
    delay_ms(1000);
    goto ali;

    }




    };
    }

    #2
    پاسخ : اینم سورس برنامه من با mt8870که ic dtmf است و با CodeVisionAVR C Compiler نوشتم

    اینم اینم که کد خالیه 1!!!!!!!!!!!!!!!!!!!
    بنظرت اگه شماتیک مدارو بذاری چطوره؟؟؟؟؟؟؟؟؟؟
    خدایا مرا آن ده که آن به

    دیدگاه


      #3
      پاسخ : اینم سورس برنامه من با mt8870که ic dtmf است و با CodeVisionAVR C Compiler نوشتم

      تاحالا نقشه بدون کد دیده بودم . اینجوریش رو دیگه ندیده بودم . آخر زمونه دیگه ...
      آموزاندن ، سپاسگذاری از خداوندگارست به جهت داشتن نعمت آموختن .

      دیدگاه


        #4
        پاسخ : اینم سورس برنامه من با mt8870که ic dtmf است و با CodeVisionAVR C Compiler نوشتم

        جواب گرفتی؟؟؟؟؟؟؟؟؟؟؟؟؟؟

        دیدگاه


          #5
          پاسخ : اینم سورس برنامه من با mt8870که ic dtmf است و با CodeVisionAVR C Compiler نوشتم

          مرسی
          دوستان حق دارن اگه شماتیک هم میذاشتی عالی بود

          دیدگاه

          لطفا صبر کنید...
          X