duda pic18f452+NDS+touchscreen 4 hilos

Saludos a todos.

Utilizo un panel táctil resistivo de 4 hilos (originalmente para Nintendo DS) y un pic18f452.

Tengo 2 dudas:

1) En varios tutoriales he observado que se conectan resistores pull-down, obviamente para cada una de las 4 lineas del panel tactil. Son estas para colocar a 0V cundo el panel no mada señales?

2) La conexion la hago directa al pic, e internamente hago los cambios necesarios para tomar los datos.

Aun no poseo domino total de la programacion(ccs) del adc, aqui va mi codigo para sugerencias o correcciones:

////////////////////////////////////////////////////////////////////////////////////////
#include <18F452.h>
#device adc=16

#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES XT //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES NOOSCSEN //Oscillator switching is disabled, main oscillator is source
#FUSES NOPUT //No Power Up Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOCPB //No Boot Block code protection
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads

#use fast_io(A)
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1)

int16 obt_x()
{
int16 x = 0;

//configuracion de pines
delay_us(20);
set_tris_a(11111010);
delay_us(20);

output_high(PIN_A0); //Vcc -> X+
output_low(PIN_A2); //Gnd -> X-
output_float(PIN_A3); //Z -> Y+

delay_us(20);
set_adc_channel(1); //adc -> Y-
delay_us(20);

x = read_adc();

delay_us(20);
set_tris_a(11111111);
delay_us(20);
return x;
}

int16 obt_y()
{
int16 y = 0;

//configuracion de pines
delay_us(20);
set_tris_a(11110101);
delay_us(20);

output_high(PIN_A1); //Vcc -> Y-
output_float(PIN_A2); //Z -> X-
output_low(PIN_A3); //Gnd -> Y+

delay_us(20);
set_adc_channel(1); //adc -> X+
delay_us(20);

y = read_adc();

delay_us(20);
set_tris_a(11111111);
delay_us(20);
return y;
}

void main()
{
int16 x = 0;
int16 y = 0;

setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(AN0_AN1_AN2_AN3_AN4);

while(true)
{
x = obt_x();
y = obt_y();

printf("%Ld %Ld", x, y);
putc(13);
putc(13);
}
}
////////////////////////////////////////////////////////////////////////////////////////

Les agradezco soberanamente de antemano.:D
Saludos.
 
Atrás
Arriba