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.

TSC2046: GUITDRV_ADS7846 Touch Screen Driver

Part Number: TSC2046
Other Parts Discussed in Thread: ADS7846,

Hi everyone,

Im using TSC2046 for my 7 inch touch screen. Im trying to configure it with GUITDRV_ADS7846 Touch Screen Driver. But i have some issues. There are some parameters in this driver. These are :

  unsigned Orientation;
  int      xLog0;
  int      xLog1;
  int      xPhys0;
  int      xPhys1;
  int      yLog0;
  int      yLog1;
  int      yPhys0;
  int      yPhys1; 

And my values for this parameters :

.Orientation = 0,
.xLog0 = 0,
.xLog1 = (800 - 1),
.xPhys0 = 0,
.xPhys1 = 4095,
.yLog0 = 0,
.yLog1 = (480 - 1),
.yPhys0 = 0,
.yPhys1 = 4095,

When i use TSC2046 with these values, the ADC values that i received are not linear. For example ;

left top ADC values for X : 2400 , for Y : 2200

left bottomADC values for X : 2150, for Y : 1276

right top ADC values for X : 1652, for Y : 2725

right bottom ADC values for X : 1810, for Y : 2710.

Can you help me with this ? How i can configure this parameters?

  • Hello,

    Your parameter values look correct, assuming your screen resolution is 800 x 480. Are you adding any capacitors at the input to filter noise? If not, the noise may be causing a gain error in the ADC. You can always take a look at the following article Reducing Analog Input Noise in Touch Screen Systems for more info on that topic. 

    Regards,

    Aaron

  • Thanks for your reply and yes my screen resolution is 800x480. I'll check capacitors for gain but when I trying same parameters with 4.3 inch screen, it works very good. Im not changing any parameter value. That 4.3 inch screen resolution is 480x272. I can not understand that. How 4.3 inch screen works well with same parameters and 7 inch does not ? 

  • Also, the ADC values in my example, are these make any sense? The noise can change that much digital values?

  • Hello,

    Size of the screen should not matter as long as the resolution is within the ADC resolution. The values you provided do not make any sense. As an example, if you are touching the left upmost corner on the screen you should, in an ideal world, see X = 0, Y = 4096.

    Can you please share the ADC values using the 4.3 inch touch screen? It could be that the 7 inch touch screen you are using needs to be properly calibrated. 

    Regards,

    Aaron

  • Hello,

    The ADC values that i wrote in first message, directly received from TSC2046. I have calibration sequence but calibrated values not right because of ADC values.

    You can compare 7inch and 4.3inch with this picture. Same hardware , same software. I can not understand why are these so different. I'm trying to use TSC2046 with emWin's GUITDRV_ADS7846 Touch Screen Driver. Could it be a problem with that driver ? 

    It configures TSC2046 with this function,

    void GUITDRV_ADS7846_Config    (GUITDRV_ADS7846_CONFIG * pConfig);

    Here are configuration parameters,

    typedef struct {
    //
    // Function pointer (1)
    //
    void (* pfSendCmd) (U8 Data); // Sends a 8-bit command to the peripheral
    U16 (* pfGetResult) (void); // Retrieves the result of the AD conversion. 4 dummy bytes have to be shifted out to the left.
    char (* pfGetBusy) (void); // Retrieves the status of the busy line. 0: Not busy; 1: Busy
    void (* pfSetCS) (char OnOff); // Set chip select line. OnOff == 1 means peripheral selected
    //
    // Configuration (2)
    //
    unsigned Orientation;
    int xLog0;
    int xLog1;
    int xPhys0;
    int xPhys1;
    int yLog0;
    int yLog1;
    int yPhys0;
    int yPhys1;
    //
    // Optional, touch recognition via PENIRQ line (3)
    //
    char (* pfGetPENIRQ) (void); // Retrieves the status of the PENIRQ line to detect a touch event.
    //
    // Optional, touch recognition via touch pressure measurement (4)
    //
    int PressureMin; // Minimum pressure threshold. A measured pressure below this value means we do not have a valid touch event.
    int PressureMax; // Maximum pressure threshold. A measured pressure above this value means we do not have a valid touch event.
    int PlateResistanceX; // Resistance of the X-plate of the touch screen. This value is needed for calculation of the touch pressure.
    } GUITDRV_ADS7846_CONFIG;

    And here are my parameters values;

    GUITDRV_ADS7846_CONFIG gui_ads7846_config=
    {
    .pfSendCmd = pfSendCmd_v,
    .pfGetResult = pfGetResult_v,
    .pfGetBusy = pfGetBusy_v,
    .pfSetCS = pfSetCS_v,
    .Orientation = 0,
    .xLog0 = 0,
    .xLog1 = (480 - 1),
    .xPhys0 = 0,//
    .xPhys1 = 4095,//
    .yLog0 = 0,
    .yLog1 = (272 - 1),
    .yPhys0 = 0,//
    .yPhys1 = 4095,//
    .pfGetPENIRQ = pfGetPENIRQ_v,
    };

    extern SPI_HandleTypeDef hspi5;

    uint16_t be_to_h_u16(const uint8_t* buf)
    {
    return (uint16_t)(buf[1] | buf[0] << 8);
    }
    void pfSendCmd_v(U8 Data)
    {

    HAL_StatusTypeDef status = HAL_SPI_Transmit(&hspi5, &Data, 1, 100);

    }

    U16 pfGetResult_v(void)
    {

    uint8_t buffer[2] = {0};
    uint8_t dummy[2] = {0};
    HAL_StatusTypeDef status = HAL_SPI_TransmitReceive(&hspi5, dummy, buffer, 2, 100);
    uint16_t result = be_to_h_u16(buffer);
    result >>= 3;
    return result;

    }
    char pfGetBusy_v(void)
    {
    return 0;
    }

    void pfSetCS_v(char OnOff)
    {
    HAL_GPIO_WritePin(GPIOF, GPIO_PIN_6, (OnOff == 1) ? GPIO_PIN_RESET : GPIO_PIN_SET); // GPIO F6

    }
    char pfGetPENIRQ_v(void)
    {
    GPIO_PinState gpio_state = HAL_GPIO_ReadPin(GPIOI, GPIO_PIN_3);
    return (gpio_state == GPIO_PIN_RESET);

    }

    Can you see anything wrong ? If you can, can you help me fix it.

    Regards,

    Ibrahim

  • I also measured X+ / X- and Y+ / Y- voltage differences.

    For 7 inch screen with touch,

    Left top corner, from X+ to X- = 1,3mV

    Right top corner, from X+ to X- = 40mV

    Left top corner, from Y+ to Y- = 0,8mV

    Left bottom corner, from Y+ to Y- = 17mV

    For 4.3 inch screen with touch,

    Left top corner, from X+ to X- = 1,5mV

    Right top corner, from X+ to X- = 35mV

    Left top corner, from Y+ to Y- = 0,7mV

    Left bottom corner, from Y+ to Y- = 11,5mV

    Regards.

  • Hi Ibrahim,

    Sorry for my delayed response.

    What screen are you using? Have you tried using a different screen? I have used a 7 inch screen with the TSC2046 and saw no issues. At first look, I do not see any issues with the code but I the found the following discussion on the web and they seem to have had similar issues with the driver and a 7 inch touch screen. It seems as if the the LCD screen calibration is the culprit. Please let me know if this helps any.

    https://forum.segger.com/index.php/Thread/1219-Regarding-caliberation-of-LCD-touch-screen/

    Regards,

    Aaron

  • HI Ibrahim,

    I have not heard back from you so I will be marking this thread as resolved. Please reply with a question if your issue is still not resolved. 

    Regards,

    Aaron