|
想在触摸屏上写字,主要是如何实现连续测量官方的程序是笔尖按下中断测量,笔尖提起事退出,一次中断中就测量一次。
我现在改成了,笔尖按下去中断测量,测量完成后退出中断,按照理论来说,退出中断后,又会马上进入中断再次测量。从而实现连续测量的效果,调了N久,最后无奈的发现只有有半边屏幕有联系的效果,左半边只能测量一个然后就没有反应了。。
void __irq AdcTsAuto(void)
{
U32 saveAdcdly;
rINTSUBMSK|=BIT_SUB_TC;
rINTMSK|=BIT_ADC;
if(rADCDAT0&0x8000)
{
// Uart_Printf("\nStylus Up!!\n");
rADCTSC&=0xff; // Set stylus down interrupt bit
}
else
// Uart_Printf("\nStylus Down!!\n");
rADCTSC=(1<<3)|(1<<2); //Pull-up disable, Seq. X,Y postion measure.
saveAdcdly=rADCDLY;
rADCDLY=40000; //Normal conversion mode delay about (1/50M)*40000=0.8ms
rADCCON|=0x1; //start ADC
while(rADCCON & 0x1); //check if Enable_start is low
while(!(rADCCON & 0x8000)); //check if EC(End of Conversion) flag is high, This line is necessary~!!
while(!(rSRCPND & (BIT_ADC))); //check if ADC is finished with interrupt bit
xdata=(rADCDAT0&0x3ff);
ydata=(rADCDAT1&0x3ff);
Uart_Printf("count=%03d XP=%04d, YP=%04d ", count++, ydata, xdata);
//check Stylus Up Interrupt.
rADCDLY=saveAdcdly;
rSUBSRCPND|=BIT_SUB_TC;
ClearPending(BIT_ADC);
rINTMSK=~BIT_ADC; //ADC Touch Screen Mask bit clear
rINTSUBMSK=~(BIT_SUB_TC);// Touch INT
rADCTSC =0xd3; //Waiting for interrupt
Delay(1);
}
自己就修改了笔尖提起中断那一部分。。有人知道什么原因吗?只有半边的触摸屏有反应
|
|