اطلاعیه

Collapse
No announcement yet.

ADC در MICROC PRO راه نمی یوفته !؟

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

    ADC در MICROC PRO راه نمی یوفته !؟

    من لا میکرو 16F877A دارم ولتمتر مینویسم ، اما کار نمیکنه
    اصلا وقتی A/D رو میارم تو کامپایل ارور میده !
    تازه کار با MICROC رو شروع کردم ، با A/D اون مشکل دارم
    مثال خودشم توش کپی می کنم ، کار نمیکنه و ارور میدهد !

    // LCD module connections
    sbit LCD_RS at RB0_bit;
    sbit LCD_EN at RB1_bit;
    sbit LCD_D4 at RB2_bit;
    sbit LCD_D5 at RB3_bit;
    sbit LCD_D6 at RB4_bit;
    sbit LCD_D7 at RB5_bit;

    sbit LCD_RS_Direction at TRISB0_bit;
    sbit LCD_EN_Direction at TRISB1_bit;
    sbit LCD_D4_Direction at TRISB2_bit;
    sbit LCD_D5_Direction at TRISB3_bit;
    sbit LCD_D6_Direction at TRISB4_bit;
    sbit LCD_D7_Direction at TRISB5_bit;
    // End LCD module connections

    char txt1[] = "10 V";
    char txt2[] = "0.123mA";
    char txt3[] = "25 V";
    char txt4[] = "0.123mA";
    char txt5[] = "WWW.GOOGLE.IR";

    unsigned int temp_res ;
    char i; // Loop variable

    void Move_Delay() { // Function used for text moving
    Delay_ms(500); // You can change the moving speed here
    }

    void main(){
    ADCON1 |= 0x0C; // Configure AN pins as digital





    TRISB = 0; // PORTB is output // PORTA is input
    temp_res = ADC_Read(2); // Get results of AD conversion
    TRISA = 0xFF; // PORTA is input
    temp_res=10;





    Lcd_Init(); // Initialize LCD

    Lcd_Cmd(_LCD_CLEAR); // Clear display
    Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
    Lcd_Out(1,1,txt1); // Write text in first row
    Lcd_Out(2,1,txt2); // Write text in second row
    Lcd_Out(1,10,txt3); // Write text in first row
    Lcd_Out(2,10,txt4); // Write text in second row
    Lcd_Out(3,5,txt5); // Write text in second row
    Lcd_Out(4,4,temp_res);
    Delay_ms(2000);


    }

    #2
    پاسخ : ADC در MICROC PRO راه نمی یوفته !؟

    یه تیک داره قسمت راست ADC رو توی کدت فعال میکنه

    دیدگاه


      #3
      پاسخ : ADC در MICROC PRO راه نمی یوفته !؟

      سلام

      اول بگم زیاد تو PIC وارد نیستم.ولی چیزی که از کدت به نظر درست نمیاد اینه که تو بعد از تابع اصلی برنامه(MAIN)
      یادت رفته ;()ADC_init رو اضافه کنی.
      دکتر شریعتی:

      زنده بودن را به بیداری بگذرانیم که سالها به اجبار خواهیم خفت.

      دیدگاه


        #4
        پاسخ : ADC در MICROC PRO راه نمی یوفته !؟

        اون تیک رو زده بودم

        ایم مثال خودشه ، که ارور می دهد
        unsigned int temp_res;

        void main() {
        ANSEL = 0x04; // Configure AN2 pin as analog
        TRISA = 0xFF; // PORTA is input
        ANSELH = 0; // Configure other AN pins as digital I/O
        TRISC = 0x3F; // Pins RC7, RC6 are outputs
        TRISB = 0; // PORTB is output

        do {
        temp_res = ADC_Read(2); // Get 10-bit results of AD conversion
        PORTB = temp_res; // Send lower 8 bits to PORTB
        PORTC = temp_res >> 2; // Send 2 most significant bits to RC7, RC6
        } while(1);
        }

        دیدگاه


          #5
          پاسخ : ADC در MICROC PRO راه نمی یوفته !؟

          من و خیلیهای دیگه تو این موضوع مونده بودیم ...!!!
          جالبیش اینه که ، مثال خودش رو هم تو کامپابل کردن ، با ارور همراه میکنه
          .
          اما راه حلش ...
          باید ته دستور ، adc این رو اضافه کنید |
          این همون دکمه بالای اینتر هست ( زیر backspace ) + فشردن shift
          مثل این ADCON1 |= 0x0C; // Configure AN pins as digital

          adcon0 |=0x00; //adc off+....f
          adcon1 |=0x0f; // an pins as digita

          دیدگاه

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