aljamri
Member
My target is to use PIC16F876A to measure 4 - 20 mA and display it on LCD. Using Assembly or C.
In my way to that, using MikroC for PIC ( Not the PRO), and while collecting the required Libraries, I’ve come to this ADC example, but found the code and the picture ( attached) are not matching …. Or am I missing something.
In my way to that, using MikroC for PIC ( Not the PRO), and while collecting the required Libraries, I’ve come to this ADC example, but found the code and the picture ( attached) are not matching …. Or am I missing something.
Code:
unsigned int temp_res;
void main() {
ADCON1 = 0x80; // Configure analog inputs and Vref
TRISA = 0xFF; // PORTA is input
TRISB = 0x3F; // Pins RB7, RB6 are outputs
TRISC = 0; // PORTD is output
do {
temp_res = Adc_Read(2); // Get results of AD conversion
PORTC = temp_res; // Send lower 8 bits to PORT C
PORTB = temp_res >> 2; // Send 2 most significant bits to RB7, RB6
} while(1);
}
Attachments
Last edited: