Pues no hay manera, en la pantalla de calibracion se me queda colgado.
Pongo aqui la modificacion del codigo para el 18f4553 haber que os parece.
/*****************************************************************
** Conexion del touchscreen resistivo de 4 hilos
** X+ = RA0/AN0
** Y+ = RA1/AN1
** X- = RA2/AN2
** Y- = RA3/AN3
*****************************************************************/
#include <18F4553.h>
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed osc with HW enabled 4X PLL
#FUSES NOPROTECT //Code not protected from reading
//#FUSES NOOSCSEN //Oscillator switching is disabled, main oscillator is source
#FUSES NOBROWNOUT //Reset when brownout detected
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES PUT //Power Up Timer
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOCPD //No EE protection
#FUSES NOCPB //No Boot Block code protection
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#use delay(clock=32000000)
#use fast_io(A)
#define FAST_GLCD;
#include <HDM64GS12.C> //Esta es la misma libreria HDM64GS12.C que trae el
//ccs pero con la asignacion de pines para la tarjeta
//easypic4.
#include <graphics.c>
---------------- Aqui va la imagen del teclado --------------------
int16 tmp;
int16 y_min,y_max,x_min,x_max;
int16 y_loc,x_loc,y_rng,x_rng;
int1 touch_flag,line_flag;
char valor_x[5];
char valor_y[4];
/****************************************************************
***** Rutina para mostrar la imagen del teclado ***
****************************************************************/
void glcd_imagen()
{
char i,j;
signed char k;
for( i = 0 ; i < 64 ; i ++ )
{
for( j = 0 ; j < 16 ; j ++)
{
for(k=7;k>-1;k--)
{
if( bit_test(Prueba[j] ,7-k ))
glcd_pixel( j*8+k,i, ON );
}
}
}
}
/**************************************************
******* Lee la coordenada y ********************
**************************************************/
int16 y_pos(void)
{
int16 result;
set_tris_a(0x04);
output_a(0x0A); //Energize X plate, RA1 and RA3
set_adc_channel(2); //Set AN2 as input
delay_us(10);
result = read_adc(); //get Y axis value
if (result != 0)
{
set_tris_a(0x01);
set_adc_channel(0);
delay_us(10);
tmp = (1023 - read_adc());
result = (result + tmp) >> 1;
}
Return(result);
}
/**************************************************
******* Lee la coordenada x ********************
**************************************************/
int16 x_pos(void)
{
int16 result;
set_tris_a(0x02);
output_a(0x05); //Energize X plate, RA1 and RA3
set_adc_channel(1); //Set AN2 as input
delay_us(10);
result = read_adc(); //get Y axis value
if (result != 0)
{
set_tris_a(0x08);
set_adc_channel(3);
delay_us(10);
tmp = (1023 - read_adc());
result = (result + tmp) >> 1;
}
Return(result);
}
/**************************************************
*** Funcion para determinar si la pantalla ***
*** ha sudo pulsada o no... ***
**************************************************/
int1 touch(void)
{
int1 resp;
int16 tmp,ty,tx;
resp=false;
ty = y_pos();
if (ty > 0)
{
delay_ms(30);
ty=y_pos();
tx=x_pos();
if (ty > y_min)
{
if(ty < y_max)
{
resp = true;
tmp=(tx - x_min) << 7;
x_loc =(int16)(tmp/x_rng);
if(x_loc > 127) x_loc = 127;
tmp = (ty - y_min) << 6;
y_loc = (int16)(tmp/y_rng);
if(y_loc > 63) y_loc = 63;
}
}
}
return(resp);
}
/*************************************************************
***** Rutina para calibrar la pantalla *******
*************************************************************/
void calibracion()
{
int1 sw;
sw=1;
while(x_pos()==0)
{
glcd_rect(0,0,2,2,YES,SW);
glcd_update();
delay_ms(100);
sw=!sw;
}
delay_ms(30);
y_min = y_pos();
x_min = x_pos();
glcd_rect(0,0,2,2,YES,OFF);
glcd_update();
while(x_pos() > 0);
delay_ms(30);
while(x_pos()==0)
{
glcd_rect(125,61,127,63,YES,SW);
glcd_update();
delay_ms(100);
sw=!sw;
}
delay_ms(30);
y_max = y_pos();
x_max = x_pos();
y_rng = y_max - y_min;
x_rng = x_max - x_min;
while(x_pos() > 0);
glcd_fillScreen(OFF);
glcd_update();
}
/**********************************************************
**** muestra las coordenadas ***************************
**********************************************************/
void print_xy_val()
{
glcd_rect(13,40,29,57,YES,OFF);
if(Touch()==true)
{
touch_flag = true;
sprintf(valor_x,"%lu",x_loc);
valor_x[4]='\0';
glcd_text57(13,40,valor_x,1,ON);
sprintf(valor_y,"%lu",y_loc);
valor_y[3]='\0';
glcd_text57(13,50,valor_y,1,ON);
}
else
{
touch_flag = false;
glcd_rect(13,40,29,57,YES,OFF);
}
//glcd_text57(1,40,x1,1,ON);
//glcd_text57(1,50,x2,1,ON);
glcd_update();
}
/*****************************************************************
****** etermina sobre que boton se ha pulsado ********
*****************************************************************/
int8 boton_act(void)
{
int8 button;
if(((x_loc>63) &&(x_loc<80)) &((y_loc>1) &&(y_loc<13))) button = '1';
if(((x_loc>83) &&(x_loc<100))&((y_loc>1) &&(y_loc<13))) button = '2';
if(((x_loc>103)&&(x_loc<120))&((y_loc>1) &&(y_loc<13))) button = '3';
if(((x_loc>63) &&(x_loc<80)) &((y_loc>17)&&(y_loc<29))) button = '4';
if(((x_loc>83) &&(x_loc<100))&((y_loc>17)&&(y_loc<29))) button = '5';
if(((x_loc>103)&&(x_loc<120))&((y_loc>17)&&(y_loc<29))) button = '6';
if(((x_loc>63) &&(x_loc<80)) &((y_loc>33)&&(y_loc<46))) button = '7';
if(((x_loc>83) &&(x_loc<100))&((y_loc>33)&&(y_loc<46))) button = '8';
if(((x_loc>103)&&(x_loc<120))&((y_loc>33)&&(y_loc<46))) button = '9';
if(((x_loc>63) &&(x_loc<80)) &((y_loc>49)&&(y_loc<62))) button = '0';
if(((x_loc>83) &&(x_loc<120))&((y_loc>49)&&(y_loc<62))) button = 'X';
return(button);
}
void main()
{
//lcd_init();
setup_adc_ports(AN0_TO_AN4);
setup_adc(ADC_CLOCK_INTERNAL );
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab
// TODO: USER CODE!!
glcd_init(ON); //Inicializa la glcd
glcd_fillScreen(OFF); //Limpia la pantalla
glcd_update();
calibracion(); //Calibra la pantalla
glcd_update();
glcd_imagen(); //muestra el teclado
glcd_update();
while(1)
{
if(touch()==true)
{
valor_x[0]=boton_act();
valor_x[1]='\0';
if (valor_x[0]=='X')
glcd_rect(27,9,37,23,YES,OFF); //Borra el numero mostrado
if ((valor_x[0]>='0')&&(valor_x[0]<='9'))
{
glcd_rect(27,9,37,23,YES,OFF); //Borra el numero mostrado antes de
glcd_text57(27,9,valor_x,2,ON); //escribir uno nuevo..
}
glcd_update();
}
}
}
-------------------------------------------------------------------------------------------------------------------------------------------
Las unicas modificaciones que he echo son los fuses y la linea que define las analogicas ya que en el 18f4553 canvia un poco y he puesto : setup_adc_ports(AN0_TO_AN4);
Pero no me funciona, en el proteus si que aparece el cuadrado parpadeando de la pantalla de calibracion, pero en mi pantalla no, por lo que tiene que ser algo de mi pantalla.