hi to all viewers in this forum,, could anyone check my code in mikroc if this is correct because i can't even read the ADC value of my PIC16F877A
porta is set as input i used RA0 as my analog input... this code i am doing i hope will display the adc value to the 3 digit 7 segment display,, when i
turn the circuit on only 000 reading is read.
what is wrong with my configuration and i don't use Vref because i want to read it until 999 i want to use only the vdd as my reference?
----------------------------------------------------------------------------------------------------------------------------------------
unsigned char get_value(unsigned char y);
unsigned char y;
unsigned char ones;
unsigned char tens;
unsigned char hundreds;
unsigned int temp_res;
void main(void)
{
ADCON1=0x80;
trisa=1;
trisb=0;
trisd=0;
while(1)
{
temp_res=Adc_Read(2);
{
hundreds=temp_res/100;
tens=(temp_res%100)/10;
ones=temp_res%10;
{
portb = get_value(hundreds);
portd=0b10000000;
delay_ms(1);
portd=0b00000000;
portb=get_value(tens);
portd=0b01000000;
delay_ms(1);
portd=0b00000000;
portb=get_value(ones);
portd=0b00100000;
delay_ms(1);
portd=0b00000000;
}
}
}
}
unsigned char get_value(unsigned char y)
{
unsigned char segments[10]={0xDE,0x50,0xE6,0xF4,0x78,0xBC,0xBE,0x54,0xFE,0xFC};
return segments[y];
}