Continue to Site

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.

Help me with ADC function problem of 16F877A

Status
Not open for further replies.

Analyzer

Full Member level 6
Joined
Nov 18, 2001
Messages
374
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Activity points
3,518
ADC Problem with 16F877A

Hi,
I'm in trouble with adc function of 16F877A.I am using port A0,A1,A5,E0,E1,E2.When i measure voltage between ports and GND they are usually at 1 milivolt or 2 milivolts.But when i log them adc function returns 100-120 values equals to 2.0V - 2.5V.When i measure E2 it gives 50 milivolt when i dont apply voltage on it(when idle i mean)!! My device does not work properly now please help!!

My code has written with ccs c compiler v3.155

My code :

#include <16F877A.h>
#device adc=8
#use delay(clock=4000000)
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)


void main() {

int v1,v2,v3,v4,v5,v6;
char ON;

setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
set_tris_d(0x00);

ON = 1;
printf("3A75D5FA\r\n");

while (1)
{

delay_ms(500);

set_adc_channel( 0 );delay_us(100);v1 = read_adc();delay_us(100);
set_adc_channel( 1 );delay_us(100);v2 = read_adc();delay_us(100);
set_adc_channel( 4 );delay_us(100);v3 = read_adc();delay_us(100);
set_adc_channel( 5 );delay_us(100);v4 = read_adc();delay_us(100);
set_adc_channel( 6 );delay_us(100);v5 = read_adc();delay_us(100);
set_adc_channel( 7 );delay_us(100);v6 = read_adc();delay_us(100);

printf("Value:%2X/%2X/%2X/%2X/%2X/%2X!",v1,v2,v3,v4,v5,v6);

if (ON == 1) {output_high(PIN_D2);ON = 0;} else {output_low(PIN_D2);ON = 1;}

v1=0;v2=0;v3=0;v4=0;v5=0;v6=0;
}

}


I uploaded schematic if you want to look at.

Analyzer.
 

Did you look at the erratas ?

**broken link removed**
**broken link removed**

I had big problems using 16F877a above 4MHz clock and returned and exchanged them to non A types.

We wanted o save some money using the A types as they are a little cheaper ...

Especially look at the manufacturing date:
big problems before 0242 !!

best luck
 

Hi,
Thank you for your reply.I am using newer mcu's.I solved the problem now.It was a hardware problem.

Analyzer.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top