This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem with TSC 2046

Other Parts Discussed in Thread: TSC2046, TSC2006

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.

  • Hello Dhiman,

    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!

    Regards,
    Wendy F.

  • 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!

    Regards,
    Wendy F.

  • Dear Dhiman,

    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.

    Regards,
    Wendy F.

  • Dear Mr.Wendy

    Sorry for delay reply. I was too much busy. I have attached the corresponding file that you asked.

    Thank you again.

    TSC_2046.zip
  • Hello Dhiman,

    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,

    • remove the 10Kohms and LED on the /PENIRQ pin; and connect the /PENIRQ to the host processor as an interrupt or GPI.
    • reduce  or eliminate the capacitance on the analog lines

     On software side:

    • before read a touch data, check the /PENIRQ status. Read touch data only when /PENIRQ is low.
    • if you need 8 bit resolution, you need to use the 24-bit (3-byte)SPI. The following is the code in TSC2046EVM firmware for your reference --

     // when /PENIRQ = 0, send convert X command
    SPISS = 0;                                        // make sure slave is selected
    spiComm(0xD0 | 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[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!

    Regards,
    Wendy F.

  • Thank you very much Mr. Wendy.
  • Dear Mr.Wendy

    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.

    Thank you again.

  • Dear Dhiman,

    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.

  • Dear Wendy,

    We were using TSC2006 so far & just few days back we got samples of 2046 as our old controller (ST10F276) is 5V.

    We are also facing similar issue & we are getting same data on every read.

    Even we got trapped in busy signal & were stuck, then got some code from net and were giving a clock delay after every transmit to read. 

    For this reason we even scraped ur cntrers SPI driver & made a bit banging SPI.

    But getting same results every time.

    After reading this thread I have started modifying my code to check the penirq & on we see that the penirq is going low on every 5th clock and remains low till 15 cycles. Can you please send us the code sample to verify what is going wrong with our software.

    I have attached our code & the file also contains the SPI wave forms.

    Channel 1 is penirq

    channel 2 is clock

    channel 3 is MOSI

    Kindly guide.

    Thanks,

    Sachin Shintre

    TSC2046_SPI_TRY.zip