#include <24fj128GA010.h>

#device ICD=TRUE

#FUSES NOWDT                 	//No Watch Dog Timer
#FUSES NOJTAG                	//JTAG disabled
#FUSES NOPROTECT             	//Code not protected from reading
#FUSES NOWRT                 	//Program memory not write protected
#FUSES NODEBUG               	//No Debug mode for ICD
#FUSES ICSP2                 	//ICD uses PGC2/PGD2 pins
#FUSES WINDIS                	//Watch Dog Timer in non-Window mode
#FUSES WPRES128              	//Watch Dog Timer PreScalar 1:128
#FUSES WPOSTS16              	//Watch Dog Timer PostScalar 1:32768
#FUSES IESO                  	//Internal External Switch Over mode enabled
#FUSES PR                    	//Primary Oscillator
#FUSES NOCKSFSM              	//Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOOSCIO               	//OSC2 is clock output
#FUSES HS                    	//High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)

#device ADC=10
#use delay(clock=8000000)
//#BYTE PMCON = 0x0600			//Definición del registro PMCON

//#define _FLEX_LCD
//#define LCD_DB4   PIN_E4
//#define LCD_DB5   PIN_E5
//#define LCD_DB6   PIN_E6
//#define LCD_DB7   PIN_E7

//#define LCD_RS    PIN_B15
//#define LCD_RW    PIN_D5
//#define LCD_E     PIN_D4


#include <25640.C>													//Libreria para el control de la EEPROM por SPI
#include <EXPLCD.C>													//Libreria que maneja el lcd de la tarjeta EXPLORER16	
																	//a través del modulo PMP del puerto D.

void main(void)
{
//bit_clear(PMCON,15);												//Pone a 0 el bit especificado, dasabilita modulo PMP
float dato1,dato;
int dato2=0,direccion=0;

setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_16|SPI_SS_DISABLED);	//ENTENDER LA CONFIGURACIÓN DEL SETUP_SPI
setup_adc_ports(ALL_ANALOG|VSS_VDD);
setup_adc (ADC_CLOCK_DIV_64); 
delay_us(10); 


init_ext_eeprom();
lcd_init(); 
delay_ms(50); 
lcd_gotoxy(1,1);
lcd_putc("Grupo GIDE");

 
do{
//set_adc_channel(5);                         //elige canal a medir
//dato=read_adc();
//delay_ms(10);
//lcd_gotoxy(1,2);
//printf(lcd_putc,"%4.0f",dato);
//delay_ms(200);

//set_adc_channel(4);                            //elige canal a medir
//dato=read_adc();
//dato2=dato2 + 1;
dato2=read_ext_eeprom(direccion);
//write_ext_eeprom(direccion, dato2);
direccion= direccion + 1;
delay_ms(500);
//dato1=(((dato*0.322265625)-32)*5)/9;
lcd_gotoxy(1,8);
printf(lcd_putc,"Temp=%3d",dato2);
//printf(lcd_putc,"Temp=%3.1f °C",dato2);
//delay_ms(200);

}while(TRUE); //bucle infinito
} 
