I am interfacing TSC2046 with Atmega16 and sending the command word 0xDF( to measure X) and 0x9F( to measure Y) through SPI bus. I am using SCK as 2MHz. But I can not receive the SPI data properly according to Touch screen and sometime the busy signal remain high and receive 00 or invalid data. The PENIRQ signal is working. What is the duration of remain high of busy signal?Please help me regarding this issue.
Hello Dhiman,
With command word 0xDF or 0x9F, you were using the single-ended mode, which is not recommended for touch function.
Suggest using the command word 0xD0 or 0x90, for 12 bit resolution; or 0xD8 or 0x98 for 8-bit resolution. For multiple reading, the PD0 should be set between samples. For example, if you would like to sample 3 times on 12-bit X data, the command words should be: (1) 0xD1, (2) 0xD1, (3) x0D0.
For your 2MHz DCLK, the duration of each DCLK is 0.5us. Note that, refer to Figure 9 on pg 15 of the d/s, the TSC2046 ADC takes 3 DCLKs (or 1.5us) to sample at the touch signal in a touch command, which is the minimal edge of the specification (Table 6 at pg 18 of the d/s). You may use a little slower DCLK rate to get more margin here.
The busy pin is redundant and something from the developing history of this device.The busy signal is always from low to high at the falling edge of the 8th DCLK, and from high to low at the falling edge of the 9th DCLK. Thus you should ignore it.
Regards,Wendy F.
Thank you Mr. Wendy
What is the recommended rate of DCLK to get appropriate data for TSC2046?
You are more than welcome!
Anything up to 2MHz should work. For test purpose, may you try 1MHz to give the TSC enough time, and tell me if there is any difference?
:-) I know Mr. Wendy the difference can not be detectable but I want the system to run at optimum speed.
Now, please suggest me one thing. How much delay should I use between transmission and receive of SPI data to avoid erroneous result. I am using 4us @ 1MHz DCLK but I am not receiving desire data at same touch i/p.
Thank you again.
As long as the DCLK rate is slower than 2MHz, the performance should be fine. However, you mentioned that you could not receiving desired touch data, which make me wondering what exact problem do you have? Is the data too noise? Or ...?
If the touch data is too noisy, the app note sbaa155a (http://www.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa155a&fileType=pdf) may help!
Dear Mr. Wendy
I have already read the app note and I am designed according to it. I also connect the capacitor to X+,X-,Y+,Y- of the touch screen. When there is no touch I am receiving Y=127 and X=000. There is same value somewhere in between two distinct points. I am sending the command word as you told. I don’t understand if there is problem with touch screen or my SPI protocol. Please suggest me the duration of delay between sending the command and receiving the data.
Dear Dhiman,
The minimal durance for data acquisition is 1.5us, as specified in Table 6 (pg 18) of the d/s, which is the time between the falling edge of the 5th DCLK and the falling edge of the 8th DCLK.
May you please send me the related PCB schematic; and the related software source code? Just for curious :-)! Thanks!
Sorry -- just want to emphasize that: the higher capacitance on the touch input lines are usually do more "bad" than "good", and thus do not add caps on the X+/X-/Y+/Y- lines unless absolutely necessary. A good practice on reducing the noise there is: (1) to have good PBC layout practice, especially good grounding; and (2) to design the analog interface as simple, as short, as secure as possible.
Dear Mr.Wendy
Sorry for delay reply. I was too much busy. I have attached the corresponding file that you asked.
Thanks for your info, which is a great help for this debugging!
Based on your schematic and software source code, I think I could totally understand why your reading is X=0 and Y=127 when there is no touch.
(1) based on the schematic, I can see you are not using the /PENIRQ pin, then your software would not know when to read from the TSC. If the touch is not applied on the panel while the X or Y is read, the X data is read from the Y+ pin which is pulled low at Y- (refer to Figure 10 of the d/s) and thus you get X=0; and the Y is read from the X+ pin which is pulled high by the 50K or 90K internal pull-up resistor and thus you get Y = 255 (the full scale at 8-bit resolution).
(2 based on your software source code, it seems you are using only 16 bits in a frame and thus you missed the LSB, which appears at the 17th bit of the DCLK after /CS low, refer to Figure 11 or 13 of the d/s. Therefore, your max is 127.
My pennies:
On hardware schematic,
On software side:
// when /PENIRQ = 0, send convert X commandSPISS = 0; // make sure slave is selectedspiComm(0xD0 | TSCConfig); // send commandresh = spiComm(0x00) & 0x7F; // clock out 8 zeros - read 1/b11-b5...resl = spiComm(0x00); // clock out 8 more zeros - read b4-b0 + 3 zeros...if (twelveBit){ read_data[1] = (resh*256 + resl)>>3;}else{ read_data[1] = (resh*256 + resl)>>7; } SPISS = 1; // deselect slave // check and find /PENIRQ = 0, send convert Y command SPISS = 0; // make sure slave is selected spiComm(0x90 | TSCConfig); // send command resh = spiComm(0x00) & 0x7F; // clock out 8 zeros - read 1/b11-b5... resl = spiComm(0x00); // clock out 8 more zeros - read b4-b0 + 3 zeros... if (twelveBit){ read_data[2] = (resh*256 + resl)>>3; } else{ read_data[2] = (resh*256 + resl)>>7; } SPISS = 1; // deselect slave
Hope the above helps!
I think I have still bug in my code. It will be grateful for me if you share whole/total code from TSC2046EVM firmware for my reference.
Sure, I will send the TSC2046EVM-PDK firmware source code to you directly, because our firmware source code is not for public. May you provide your email address?
Thanks,Wendy F.
Dear Mr Wendy
It's "dhiman.das19@gmail.com"
It will be really grateful for me.
Thanks Wendy, your comments are very helpful.