Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

whats wrong with this code? correct me with this

Status
Not open for further replies.

denz

Newbie level 5
Joined
May 12, 2009
Messages
8
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Philippines
Activity points
1,333
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];

}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top