- Here I am using the PIC16 8 bit MCU version that is PIC16F887A.
- Here the idea is to disable the comparators to enable the process of signal conversion.
- The PORT C or the PORTD LEDs can be toggled as the user wishes.
The Test configuration:
Microcontroller unit: PIC16F887
Development.Board: EasyPIC6 – ac:ADC
Oscillator frequency : 8.0000 MHz
Ext. Modules: –
Software used : mikroC PRO(PIC)
unsigned int tem_res;//temporary result stored in the variable temp res
ANSEL = 0x04; // AN2 pin configured as analog input
ANSELH = 0; // Rest other AN pins to be configured as digital Input/Outptut pins
C1ON_bit = 0; // Disable the available comparators
C2ON_bit = 0;
TRISD = 0xFF; // PORTA is regarded as input
TRISA = 0; // PORTC is assigned as output
TRISC = 0; // PORTD is assigned output
tem_res = ADC_Read(2); // Obtain the corresponding results of AD conversion(10 bits)
PORTC = temp_res; // Lowermost 8 bits assigned to PORTD
PORTA = temp_res >> 8; // The most significant bits are assigned to RC1, RC0
} while(1);While logic is high