go_away

Author Topic: pic16f877  (Read 2918 times)

0 Members and 1 Guest are viewing this topic.

Offline medo31Topic starter

  • Beginner
  • *
  • Posts: 1
  • Helpful? 0
pic16f877
« on: April 12, 2010, 02:27:54 PM »
i want help  in a2d  in mikroc

to  program  pic 16f877

program canot define the (ansel) code




void main() {
  ANSEL  = 0x04;              // Configure AN2 pin as analog- errror  here??????
  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);
}



Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,919
  • Helpful? 97
Re: pic16f877
« Reply #1 on: April 12, 2010, 02:59:52 PM »
Try looking at the Mikrco header file for the PIC16F877. My first guess is that it has a different name.

Just re-checked the 16F877 data sheet and that PIC does not have a ANSEL or a ANSELH register, Figure 2-3.
Did you include the correct header file?

The ADCON0 & ADCON1 registers has the analog input selection and ADC setup bits, section 11.0.

 


Get Your Ad Here

data_list