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.

TM4C1294NCPDT: Problem with TSC2003 touch screen controller temperature connected to TM4C1294NCPDT

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: TSC2003

Hello,

I also posted this on the touch forum but I figured I might get some feedback here too since I am using the TM4C1294.

I am trying figure out how to read temperature using the TSC2003. It looks like I implemented my I2C drivers correctly because I am able to measure X and Y okay and I am able to implement touch screen feature. But I could not get the right temperature readings. Any suggestions on what I am doing wrong? I am using the TM4C1294NCPDTI. Some of the lines I wrote might not make sense because I have tried so many things and I just could not get reading the temperature to work.

void InitializeTouch(void)
{
 //PENIRQ pin
 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
 while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOC))
 {
 }//end while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOC))
 
 GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_4);
 GPIOIntTypeSet(GPIO_PORTC_BASE, GPIO_PIN_4, GPIO_FALLING_EDGE); 
// GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
 
 GPIOIntRegister(GPIO_PORTC_BASE, PortCIntHandler);
 GPIOIntEnable(GPIO_PORTC_BASE, GPIO_PIN_4);
 
 //Touch I2C pins
 SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C6);
 while(!SysCtlPeripheralReady(SYSCTL_PERIPH_I2C6))
 {
 }//end while(!SysCtlPeripheralReady(SYSCTL_PERIPH_I2C6))
 
 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
 while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA))
 {
 }//end while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOA)) 
 
 GPIOPinConfigure(GPIO_PA6_I2C6SCL);
 GPIOPinConfigure(GPIO_PA7_I2C6SDA);
  GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_6);
  GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_7); 
 
 //I2C1
 I2CMasterInitExpClk(I2C6_BASE, FOSC_HZ, false); 
 
 //chip initialize
 WriteTouchByte(0x90, 0x02);
 PollTimer0Delay(20, 1000);
 ReadTouchByte(0x90);
}//end void InitializeTouch(void)
/***********************************************/
void WriteTouchByte(uint8_t i2cAdd,  uint8_t commandByte)
{
 i2cAdd = i2cAdd >> 1;
 I2CMasterSlaveAddrSet(I2C6_BASE, i2cAdd, false);
 I2CMasterDataPut(I2C6_BASE, commandByte);
 I2CMasterControl(I2C6_BASE, I2C_MASTER_CMD_SINGLE_SEND);
 
 PollTimer0Delay(50, 1000000);
 while(I2CMasterBusy(I2C6_BASE))
 {
 }
}//end void WriteTouchByte(uint8_t i2cAdd,  uint8_t commandByte)
/***********************************************/
uint8_t ReadTouchByte(uint8_t i2cAdd)
{
 uint32_t i2cByte;
 i2cAdd = i2cAdd >> 1;
 
 I2CMasterSlaveAddrSet(I2C6_BASE, i2cAdd, true);
 I2CMasterControl(I2C6_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
 PollTimer0Delay(50, 1000000);
 while(I2CMasterBusy(I2C6_BASE));
 i2cByte = I2CMasterDataGet(I2C6_BASE);
 
 return((uint8_t)i2cByte);
}//end uint8_t ReadTouchByte(uint8_t i2cAdd)
/***********************************************/

This is the code in my main

     WriteUART0("\n\rTouch Temp1 = ");
     WriteTouchByte(0x90, 0x0E);
     PollTimer0Delay(20, 1000);
     touchTemp1 = ReadTouchByte(0x90);
     UINT32ToASCII((uint32_t)touchTemp1);
     WriteUART0(decimal_string);

     WriteTouchByte(0x90, 0x02);  
     PollTimer0Delay(20, 1000);
     ReadTouchByte(0x90);

     PollTimer0Delay(5, 1);

     WriteUART0("\n\rTouch Temp2 = ");
     WriteTouchByte(0x90, 0x4E); 
     PollTimer0Delay(20, 1000); 
     touchTemp2 = ReadTouchByte(0x90);
     UINT32ToASCII((uint32_t)touchTemp2);
     WriteUART0(decimal_string); 
     
     WriteTouchByte(0x90, 0x02);  
     PollTimer0Delay(20, 1000);
     ReadTouchByte(0x90);
     
     Temperature = touchTemp1 * 2.5 / 255 * 1000.0 * 25.0 / 600;
     WriteUART0("\n\rTemp0(C) = ");
     DoubleToASCII(Temperature);
     WriteUART0(decimal_string);

     Temperature = (2.573 * (touchTemp2 - touchTemp1) * 2.5 / 255 * 1000) - 273;
     WriteUART0("\n\rTemp1(C) = ");
     DoubleToASCII(Temperature);
     WriteUART0(decimal_string);    

This is what I see on hyperterminal. And no matter what the temperature around is, it's always like this.

Touch Temp1 = 76
Touch Temp2 = 92
Temp0(C) = 31.04
Temp1(C) = 130.60

Thanks.

AJ

  • Hi,
    If you are able to read the measurement of X and Y correctly then I think the hardware setup is mostly right.

    I will suggest that you use the scope monitor what is returned by the TSC2003 when you do ReadTouchByte(0x90). Is the data correct on the scope? If the data is correct on the scope then the problem is likely due to the software.

    I read the TSC2003 datasheet and it says you need to wait 10us after you issue a command before you can read the data? Did your PollTimer0Delay() meet this requirement? After you issue the command, the TSC2003 needs to start the acquisition and then conversion. If you read too early before the data is ready then the data can be wrong. Just a thought though.