触摸屏坐标定位问题
void __irq AdcTsAuto(void){
U32 saveAdcdly;
if(rADCDAT0&0x8000) // ADCDAT 位15: 0为按下 1为弹起状态
{
//Uart_Printf("\nStylus Up!!\n");
rADCTSC&=0xff; // Set stylus down interrupt bit
}
//else
//Uart_Printf("\nStylus Down!!\n");
rADCTSC=(1<<3)|(1<<2); //ADCTSC 位3 上拉开关使能 1为XP上拉无效
// 位2 1为连续测量X Y
saveAdcdly=rADCDLY;
rADCDLY=40000;
rADCCON|=0x1; //ADCCON 位0 AD转换开始标志位 1为开始 自动清零
while(rADCCON & 0x1); //检测AD转换开始标志位是否清零
while(!(rADCCON & 0x8000)); //ADCCON 位15 转换结束标志位 1为结束
while(!(rSRCPND & (BIT_ADC))); //check if ADC is finished with interrupt bit
xdata=(rADCDAT0&0x3ff); //ADCDAT 位9到位0 AD转换数据位
ydata=(rADCDAT1&0x3ff);
//check Stylus Up Interrupt.
rSUBSRCPND|=BIT_SUB_TC; //* BIT_SUB_TC可能是抬起按下检测的自动置位
ClearPending(BIT_ADC);
rINTSUBMSK=~(BIT_SUB_TC); //*
rINTMSK=~(BIT_ADC); //*
rADCTSC=0xd3; //* //位1~0:手动测量XY 位2: 1为自动检测
rADCTSC=rADCTSC|(1<<8); //ADCTSC 位8: 1为抬起状态
while(1) //to check Pen-up state
{
// 在循环内实时检测坐标位置
if(rSUBSRCPND & (BIT_SUB_TC)) //check if ADC is finished with interrupt bit
{
//Uart_Printf("Stylus Up Interrupt~!\n");
// 在跳出循环时将数据赋值
break; //if Stylus is up(1) state
}
}
Uart_Printf("count=%03d XP=%04d, YP=%04d\n", count++, xdata, ydata);
//X-position Conversion data
rADCDLY=saveAdcdly;
rADCTSC=rADCTSC&~(1<<8); //抬起后改为检测按下中断信号
rSUBSRCPND|=BIT_SUB_TC;
rINTSUBMSK=~(BIT_SUB_TC); // Unmask sub interrupt (TC)
ClearPending(BIT_ADC);
}
如何获取笔针弹起点的坐标
页:
[1]