#include <16F690.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES MCLR //Master Clear pin enabled
#FUSES NOCPD //No EE protection
#FUSES PUT //Power Up Timer
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#use delay(clock=4000000)
#define LCD_ENABLE_PIN PIN_C0 ////
#define LCD_RS_PIN PIN_C1 ////
#define LCD_RW_PIN PIN_C2 ////
#define LCD_DATA0 PIN_C4 ////
#define LCD_DATA1 PIN_C5 ////
#define LCD_DATA2 PIN_C6 ////
#define LCD_DATA3 PIN_C7
#include "lcd.c"
int valor=0x00;
int valor1=0x00;
const float vccmax1=15.22;
const float vccmax=15.11;
void cortocircuito()
{
do
{
printf(lcd_putc
," Corto Circuito presionar reset");
}
while(true);
}
void toma_adc(void)
{
// Lectura del canal 0
set_adc_channel(0);
delay_ms(1);
valor=read_adc();
delay_ms(1); //para que se estabilice
// Lectura del canal 1
set_adc_channel(1);
delay_ms(1);
valor1=read_adc();
delay_ms(1); //para que se estabilice
}
void main()
{
float tension=0;
float tension1=0;
setup_adc_ports(sAN0|sAN1|VSS_VDD); // Entradas analogas AN0 y AN1
setup_adc(ADC_CLOCK_INTERNAL); //configura el converso
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
lcd_init();
do
{
delay_ms(100);
toma_adc();
tension=(valor*vccmax)/255;
tension1=(valor1*vccmax1)/255;
Vcc- -%3.1f V",tension,tension1);
}
while(true);
}