HI,
im using Mikroc compiler 8.2 with PIC16F877A and Proteus7.5 to simulate touch screen using a model i download form the internet.
OSRAM Touch Screen Pictiva OLED display Proteus VSM Model
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:
----------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
the problem is the rectangle never be drawn.
please help me, i need to get this done.

oh, by theway the my proteus schematic is in the link below.
**broken link removed**
Thank you in advance.
Ramzi,
im using Mikroc compiler 8.2 with PIC16F877A and Proteus7.5 to simulate touch screen using a model i download form the internet.
OSRAM Touch Screen Pictiva OLED display Proteus VSM Model
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:
----------------------------------------------------------------------------------------------
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.
oh, by theway the my proteus schematic is in the link below.
**broken link removed**
Thank you in advance.
Ramzi,