Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

touchscreen simualtion with proteus 7.5

Status
Not open for further replies.

xsystemxr

Newbie level 1
Joined
Nov 16, 2007
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,305
proteus 7.5

HI,

im using Mikroc compiler 8.2 with PIC16F877A and Proteus7.5 to simulate touch screen using a model i download form the internet.

http://www.tanu-sha.narod.ru/ts128x64.html

The problem is that the touchscreen model is with built-in AD7843 (touchscreen controller), i triad to write code to communicate with the AD7843 using SPI, but unfortunately there is no any response except the PENIRQ is activated and then could not be use any more.

according to the datasheet of AD7843 and the document with the touch screen proteus model , you need to send 0X98 to get the X component and send 0XD8 for the Y component.

the function of the code i wrote is to get the coordinate once there is an interrupt coming from the PENIRQ (active low) and never come back again, after testing and trying, i think that maybe my problem is SPI i think i dont know how to use it.

Code:
----------------------------------------------------------------------------------------------
unsigned short x=0,y=0,ax=0,ay=0,bx=0,by=0,flag=0;
//float gx=0.0,gy=0.0,mx=0.0,my=0.0;
void interrupt()
{
//Spi_Init_Advanced(MASTER_OSC_DIV4, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, HIGH_2_LOW);
Spi_Init();
PORTB.F1=0; //for chip select
Spi_Write(0x98); //for x readign
spi_read(0);
Spi_Write(0xD8); //for y reading
y=spi_read(0);

INTCON.INTF=0; // resetting the interrupt
OPTION_REG=0;
PORTB.F1=1; //disable the chip select after getting x and y
flag=1; //flag to indicate that a touch occur


}

//unsigned short xx(unsigned short x)
//{return ((x*gx)+mx);}

//unsigned short yy(unsigned short y)
//{return ((y*gy)+my);}

void main()
{
TRISC &= 0x14;
TRISB &= 0x01;

PORTB.F1=1;

Glcd_Init(&PORTB,2,3,4,5,7,6,&PORTD);

Glcd_Circle(15, 7, 2, 2); // a small circule to touched
flag=0; //falg initiating
INTCON.INTE=1; //enable external interrupt (RB0)
INTCON.GIE=1;
OPTION_REG=0;


while(1) //setting ax and ay if the falge is set
{
if(flag)
{
ax=x;
ay=y;
break;
}

}

Glcd_Circle(111, 55, 2, 2); // another small circule to touched
flag=0; //flag initiating

while(1) //setting bx and by if the falge is set
{
if(flag)
{
bx=x;
by=y;
break;


}
}

glcd_rectangle(31,15,95,47,2); // to indicate that both circuls received
// a touch
-------------------------------------------------------------------------------------------------


the problem is the rectangle never be drawn.

please help me, i need to get this done. :cry::?:

oh, by theway the my proteus schematic is in the link below.


**broken link removed**

Thank you in advance.

Ramzi,
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top