اطلاعیه

Collapse
No announcement yet.

کمک در مورد lcd

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

    کمک در مورد lcd

    /************************************************** ***
    This program was produced by the
    CodeWizardAVR V2.05.3 Standard
    Automatic Program Generator
    © Copyright 1998-2011 Pavel Haiduc, HP InfoTech s.r.l.
    http://www.hpinfotech.com

    Project :
    Version :
    Date : 2011/12/13
    Author : PerTic@n
    Company : If You Like This Software,Buy It
    Comments:


    Chip type : ATmega16
    Program type : Application
    AVR Core Clock frequency: 16.000000 MHz
    Memory model : Small
    External RAM size : 0
    Data Stack size : 256
    ************************************************** ***/

    #include <mega16.h>
    #include <delay.h>
    #include <string.h>
    #include <stdlib.h>
    // Alphanumeric LCD functions
    #include <alcd.h>
    int i;
    unsigned char data,col[18];
    flash unsigned char c0[]="0";
    flash unsigned char c1[]="1";
    flash unsigned char c2[]="2";
    flash unsigned char c3[]="3";
    flash unsigned char c4[]="4";
    flash unsigned char c5[]="5";
    flash unsigned char c6[]="6";
    flash unsigned char c7[]="7";
    flash unsigned char c8[]="8";
    flash unsigned char c9[]="9";
    flash unsigned char cp[]="<-";
    flash unsigned char c10[]="up";
    flash unsigned char c11[]="down";
    flash unsigned char c12[]="step";
    flash unsigned char c13[]="degri";
    flash unsigned char c14[]="->";

    void coding(unsigned char ha){
    switch (ha)
    {
    case 1:
    *strcatf(col,c1);
    break;
    //***************
    case 2:
    *strcatf(col,c2);
    break;
    //***************
    case 3:
    *strcatf(col,c3);
    break;
    //***************
    case 4:
    *strcatf(col,c4);
    break;
    //***************
    case 5:
    *strcatf(col,c5);
    break;
    //***************
    case 6:
    *strcatf(col,c6);
    break;
    //***************
    case 7:
    *strcatf(col,c7);
    break;
    //***************
    case 8:
    *strcatf(col,c8);
    break;
    //***************
    case 9:
    *strcatf(col,c9);
    break;
    //***************
    case 0x31:
    *strcatf(col,c0);
    break;
    //***************
    case 0x55:
    *strcatf(col,cp);
    break;
    //***************
    case 0x40:
    *strcatf(col,c10);
    break;
    //***************
    case 0x41:
    *strcatf(col,c11);
    break;
    //***************
    case 0x42:
    *strcatf(col,c12);
    break;
    //***************
    case 0x43:
    *strcatf(col,c13);
    break;
    //***************
    case 0x44:
    *strcatf(col,c14);
    break;
    }
    }
    void ref_key(void){
    DDRC=0x0f;
    //*********************
    PORTC=0xff;
    PORTC.0=0;
    delay_ms(15);
    if(PINC.4==0)data=1;
    if(PINC.5==0)data=2;
    if(PINC.6==0)data=3;
    if(PINC.7==0)data=0x40;
    //**********************
    PORTC=0xff;
    PORTC.1=0;
    delay_ms(15);
    if(PINC.4==0)data=4;
    if(PINC.5==0)data=5;
    if(PINC.6==0)data=6;
    if(PINC.7==0)data=0x41;
    //**********************
    PORTC=0xff;
    PORTC.2=0;
    delay_ms(15);
    if(PINC.4==0)data=7;
    if(PINC.5==0)data=8;
    if(PINC.6==0)data=9;
    if(PINC.7==0)data=0x42;
    //**********************
    PORTC=0xff;
    PORTC.3=0;
    delay_ms(15);
    if(PINC.4==0)data=0x55;
    if(PINC.5==0)data=0x31;
    if(PINC.6==0)data=0x44;
    if(PINC.7==0)data=0x43;
    //**********************
    }
    // External Interrupt 0 service routine
    interrupt [EXT_INT0] void ext_int0_isr(void)
    {

    // Place your code here

    }

    // External Interrupt 1 service routine
    interrupt [EXT_INT1] void ext_int1_isr(void)
    {
    for(i=0;i<=5;i++){
    lcd_putsf("masoud"
    delay_ms(2000);
    ref_key();
    }
    coding(data);
    lcd_puts(col);
    data=0;
    delay_ms(50);
    PORTC=0x00;

    // Place your code here

    }

    // Timer 0 overflow interrupt service routine
    interrupt [TIM0_OVF] void timer0_ovf_isr(void)
    {
    // Place your code here

    }

    // Declare your global variables here

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

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

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

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

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

    // Timer/Counter 0 initialization
    // Clock source: System Clock
    // Clock value: 16000.000 kHz
    // Mode: CTC top=OCR0
    // OC0 output: Disconnected
    TCCR0=0x09;
    TCNT0=0x00;
    OCR0=0x00;

    // Timer/Counter 1 initialization
    // Clock source: System Clock
    // Clock value: Timer1 Stopped
    // Mode: Normal top=0xFFFF
    // OC1A output: Discon.
    // OC1B output: Discon.
    // Noise Canceler: Off
    // Input Capture on Falling Edge
    // Timer1 Overflow Interrupt: Off
    // Input Capture Interrupt: Off
    // Compare A Match Interrupt: Off
    // Compare B Match Interrupt: Off
    TCCR1A=0x00;
    TCCR1B=0x00;
    TCNT1H=0x00;
    TCNT1L=0x00;
    ICR1H=0x00;
    ICR1L=0x00;
    OCR1AH=0x00;
    OCR1AL=0x00;
    OCR1BH=0x00;
    OCR1BL=0x00;

    // Timer/Counter 2 initialization
    // Clock source: System Clock
    // Clock value: Timer2 Stopped
    // Mode: Normal top=0xFF
    // OC2 output: Disconnected
    ASSR=0x00;
    TCCR2=0x00;
    TCNT2=0x00;
    OCR2=0x00;

    // External Interrupt(s) initialization
    // INT0: On
    // INT0 Mode: Rising Edge
    // INT1: On
    // INT1 Mode: Falling Edge
    // INT2: Off
    GICR|=0xC0;
    MCUCR=0x0B;
    MCUCSR=0x00;
    GIFR=0xC0;

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

    // USART initialization
    // USART disabled
    UCSRB=0x00;

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

    // ADC initialization
    // ADC disabled
    ADCSRA=0x00;

    // SPI initialization
    // SPI disabled
    SPCR=0x00;

    // TWI initialization
    // TWI disabled
    TWCR=0x00;

    // Alphanumeric LCD initialization
    // Connections are specified in the
    // Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu:
    // RS - PORTA Bit 0
    // RD - PORTA Bit 1
    // EN - PORTA Bit 2
    // D4 - PORTA Bit 4
    // D5 - PORTA Bit 5
    // D6 - PORTA Bit 6
    // D7 - PORTA Bit 7
    // Characters/line: 8
    lcd_init(16);

    // Global enable interrupts
    #asm("sei&quot

    while (1)
    {lcd_putsf("dadgar"
    delay_ms(200);
    lcd_clear();
    lcd_puts(col);
    delay_ms(200);

    // Place your code here

    }
    }

    #2
    پاسخ : کمک در مورد lcd

    هر کار کردم جواب نداد

    دیدگاه


      #3
      پاسخ : کمک در مورد lcd

      این کد برای تابع کدویژن ورژن 5 هست.
      درسته؟
      دودمانم بر باد رفت

      دیدگاه


        #4
        پاسخ : کمک در مورد lcd

        سلام گلم.
        مثلا چی کار کردی؟
        ?Why not

        دیدگاه


          #5
          پاسخ : کمک در مورد lcd

          vala in barname az amozeshe microcontoroler avr be zaban c hamid badami nejat hast

          دیدگاه

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