STMPE610 touch difficulties

General discussion on mikroElektronika development boards.
Post Reply
Author
Message
barbiani
Posts: 8
Joined: 13 Jun 2014 19:46

STMPE610 touch difficulties

#1 Post by barbiani » 18 Apr 2015 02:34

Hi,

I wrote a driver for this chip on a pic32mx mikromedia+ board and sometimes I get a 0;0 reading.

This is one line for each touch event.

Code: Select all

x= 393  y= 703
x= 391  y= 682
x= 397  y= 663
x= 401  y= 670
x= 400  y= 660
x= 408  y= 661
x= 0  y= 0
x= 403  y= 679

Code: Select all

TOUCH * STMPE610_read (TOUCH *touch) {
    if (read_byte(STMPE_TSC_CTRL) & STMPE_TSC_TOUCH_DET) {
        touch->x = read_word(STMPE_TSC_DATA_X);
        touch->y = read_word(STMPE_TSC_DATA_Y);
        DBPRINTF("x= %lu  y= %lu\n", touch->x, touch->y);
    }
    write(STMPE_FIFO_STA, STMPE_FIFO_STA_RESET);
    write(STMPE_FIFO_STA, 0);
    return (touch);
}
It seems that the chip is setting STMPE_TSC_TOUCH_DET bit with empty buffers?

Did anyone else have seen this problem?

Thank you.

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: STMPE610 touch difficulties

#2 Post by marina.petrovic » 20 Apr 2015 14:04

Hi,

I wasn't able to reproduce the same behavior with compiler STMPE610 Library routines.

I tested simple example from our compiler written for mikromedia Plus for PIC32MX7 and
only add reading of the X and Y coordinates inside Check_TP() routine (send coordinates over UART):

Code: Select all

void Check_TP() {
  if (STMPE610_PressDetect()) {
    // After a PRESS is detected read X-Y and convert it to Display dimensions space
    if (STMPE610_GetLastCoordinates(&Xcoord, &Ycoord) == 0) {
      Process_TP_Press(Xcoord, Ycoord);
      if (PenDown == 0) {
        PenDown = 1;
        Process_TP_Down(Xcoord, Ycoord);
      }
    }
  }
  else if (PenDown == 1) {
    PenDown = 0;
    Process_TP_Up(Xcoord, Ycoord);
  }
}
Also, please, take a look at STMPE610_Config() routine in the example:

Code: Select all

char STMPE610_Config() {
  STMPE610_SetI2CAddress(STMPE610_I2C_ADDR1);
  if(STMPE610_IsOperational()) {
    return STMPE610_IO_NOT_OPERATIONAL;
  }

  STMPE610_Reset();
  STMPE610_Module(STMPE610_MODULE_TS | STMPE610_MODULE_ADC, STMPE610_ENABLE);
  STMPE610_AlternateFunction(STMPE610_GPIO_PIN1, STMPE610_ENABLE);
  STMPE610_SetGPIOPin(STMPE610_GPIO_PIN1, 0);   // IN1 to "0" -> I2C communication
  STMPE610_SetSize(480,272);
  STMPE610_Module(STMPE610_MODULE_TS | STMPE610_MODULE_ADC, STMPE610_ENABLE);
  STMPE610_EnableInterrupt(0, STMPE610_ENABLE);
  STMPE610_ConfigureInterrupt(STMPE610_INT_POLARITY_ACTIVE_HIGH | STMPE610_INT_TYPE_EDGE | STMPE610_INT_ENABLE_ALL);
  STMPE610_SetADC(STMPE610_ADC_CTRL1_SAMPLETIME_56 | STMPE610_ADC_CTRL1_ADC_12BIT | STMPE610_ADC_CTRL1_INT_REFERENCE);
  Delay_10ms(); Delay_10ms();
  STMPE610_SetADCClock(STMPE610_ADC_CTRL2_3250_kHZ);
  STMPE610_AlternateFunction(STMPE610_GPIO_PIN4 | STMPE610_GPIO_PIN5 | STMPE610_GPIO_PIN6 | STMPE610_GPIO_PIN7, STMPE610_DISABLE);
  STMPE610_ConfigureTSC(STMPE610_TSC_CFG_AVE_CTRL_4S, STMPE610_TSC_CFG_TOUCH_DET_DELAY_500uS, STMPE610_TSC_CFG_TOUCH_SETTLING_1mS);
  STMPE610_SetFIFOThreshold(1);
  STMPE610_ResetFIFO();
  STMPE610_TSIDrive(STMPE610_TSC_I_DRIVE_20mA);
  STMPE610_TSControl(STMPE610_TSC_CTRL_TRACK0 | STMPE610_TSC_CTRL_ACQU_XYZ | STMPE610_TSC_CTRL_ENABLE);
  STMPE610_ZDataFraction(STMPE610_FRACP4_WHOLP4);
  STMPE610_SetTouchPressureThreshold(45);
  STMPE610_ClearInterrupts();
  STMPE610_WriteReg(STMPE610_INT_CTRL_REG, 0x01);
  return STMPE610_OK;
}
Best regards,
Marina

barbiani
Posts: 8
Joined: 13 Jun 2014 19:46

Re: STMPE610 touch difficulties

#3 Post by barbiani » 21 Apr 2015 05:11

What does STMPE610_PressDetect() test?

I am using the board with xc32, so I am having to write my own drivers.

Touch detect Interrupt is correctly assigned. I can see both down and up events, but I am having problems reading the fifo contents.

I get always the same first coordinate.. or get zeroes sometimes.

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: STMPE610 touch difficulties

#4 Post by marina.petrovic » 21 Apr 2015 09:51

Hi,

STMPE610_PressDetect() function detects if touch panel has been pressed and returns PenDown value.

This function returns:
- One: if touchscreen has been pressed.
- Zero: if touchscreen hasn't been pressed.
Additionally, function returns value of PenDown (detects changes on touchscreen, PressDown or PressUp).

Also, please, note that this function resets FIFO buffer.

Best regards,
Marina

barbiani
Posts: 8
Joined: 13 Jun 2014 19:46

Re: STMPE610 touch difficulties

#5 Post by barbiani » 21 Apr 2015 10:40

I think that I am following the right sequence... but getting (0,0) sometimes. Maybe reading from empty fifo?

Code: Select all

TOUCH * STMPE610_read (TOUCH *touch) {
    if ((read_byte(STMPE_TSC_CTRL) & STMPE_TSC_TOUCH_DET)) {
        touch->x = read_word(STMPE_TSC_DATA_X);
        touch->y = read_word(STMPE_TSC_DATA_Y);
        write(STMPE_FIFO_STA, STMPE_FIFO_STA_RESET);
        write(STMPE_FIFO_STA, 0);
    } else {
        touch->x = -1;
        touch->y = -1;
    }
    DBPRINTF("%lu;%lu\n", touch->x, touch->y);
    return (touch);
}

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: STMPE610 touch difficulties

#6 Post by marina.petrovic » 22 Apr 2015 08:53

Hi,

Like I already mentioned, with compiler library routines I wasn't able to reproduce the same behavior.
I also consulted my colleague from Software Department but he wasn't able to give me some information regarding problem
which you have.

Maybe problem is related with empty FIFO buffer, like you mentioned.
If there is no any information regarding this behavior in STMPE610 datasheet, you should contact manufacturer of this chip, maybe they can give you some useful information.

Best regards,
Marina

Post Reply

Return to “Development Boards”