Society of Robots - Robot Forum
Software => Software => Topic started by: medo31 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);
}
-
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.