Hola, ando buscando ayuda, el problema es que no hace el calculo como debe ser, uso ccs pcwh y lo simulo en proteus 6.7
#include <16F877A.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES BROWNOUT //Reset when brownout detected
#FUSES NOLVP //No Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#ZERO_RAM
void main()
{
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_RDA) ;
enable_interrupts(GLOBAL) ;
while(true) {
int i=0 ;
float con ;
int valor=0 ;
while (i < 5) {
set_adc_channel(i) ;
delay_us(20) ;
valor=read_adc() ;
con = (valor * 5 / 255) ;
printf("
Adc-%1u / Valor: %03u / Con: %04u ",i,valor,con) ;
delay_ms(1000) ;
con=0, valor=0 ;
if (i==4)
i=0 ;
else
i++ ;
}
}
}
en la variable valor=read_adc para una toma de 1V me da 051 y en la variable con me da 0127, bueno me gustaria si alguien lo puede revisar y decirme donde me estoy equivocando, muchas gracias.