Hi,
I am trying to interfacing touchscreen controller ADS7843. I have connected PENIRQ of TS controller to P30 of mbed. Following is the code.....
#include "mbed.h"
SPI spi(p5, p6, p7); // mosi, miso, sclk
DigitalOut cs(p8);
InterruptIn button(p30);
//DigitalIn PI(p30);
Serial pc(USBTX, USBRX); // tx, rx
unsigned short TPReadX(void)
{
unsigned short x=0;
cs = 0;
wait_us(10);
spi.write(0x90);
wait_us(10);
x=spi.write(0x00);
x<<=8;
x+=spi.write(0x00);
wait_us(10);
cs = 1;
x = x>>3;
return (x);
}
unsigned short TPReadY(void)
{
unsigned short y=0;
cs = 0;
wait_us(10);
spi.write(0xD0);
wait_us(10);
y=spi.write(0x00);
y<<=8;
y+=spi.write(0x00);
wait_us(10);
cs = 1;
y = y>>3;
return (y);
}
void flip() {
pc.printf("\rX = 0x%X Y = 0x%X ",TPReadX(),TPReadY() );
wait(0.2);
}
int main() {
unsigned long x_axis;
spi.format(8,3);
spi.frequency(1000000);
cs=1;
pc.printf("\rTS testing\n");
pc.printf("\n");
button.fall(&flip); // attach the address of the flip function to the rising edge
while(1)
{
// while(PI);
//flip();
}
}
The problem is that mbed gets interrupted even if TS is not touched(P30 used as interrupt in). But when I use polling method, I get readings only when I touch the TS.....
Please help on this......
Thanks
Nitin
Hi,
I am trying to interfacing touchscreen controller ADS7843. I have connected PENIRQ of TS controller to P30 of mbed. Following is the code.....
#include "mbed.h"
SPI spi(p5, p6, p7); // mosi, miso, sclk
DigitalOut cs(p8);
InterruptIn button(p30);
//DigitalIn PI(p30);
Serial pc(USBTX, USBRX); // tx, rx
unsigned short TPReadX(void)
{
unsigned short x=0;
cs = 0;
wait_us(10);
spi.write(0x90);
wait_us(10);
x=spi.write(0x00);
x<<=8;
x+=spi.write(0x00);
wait_us(10);
cs = 1;
x = x>>3;
return (x);
}
unsigned short TPReadY(void)
{
unsigned short y=0;
cs = 0;
wait_us(10);
spi.write(0xD0);
wait_us(10);
y=spi.write(0x00);
y<<=8;
y+=spi.write(0x00);
wait_us(10);
cs = 1;
y = y>>3;
return (y);
}
void flip() {
pc.printf("\rX = 0x%X Y = 0x%X ",TPReadX(),TPReadY() );
wait(0.2);
}
int main() {
unsigned long x_axis;
spi.format(8,3);
spi.frequency(1000000);
cs=1;
pc.printf("\rTS testing\n");
pc.printf("\n");
button.fall(&flip); // attach the address of the flip function to the rising edge
while(1)
{
// while(PI);
//flip();
}
}
The problem is that mbed gets interrupted even if TS is not touched(P30 used as interrupt in). But when I use polling method, I get readings only when I touch the TS.....
Please help on this......
Thanks
Nitin