D
D
Dixi_Alex2014-09-20 00:14:05
Do it yourself
Dixi_Alex, 2014-09-20 00:14:05

Using Touch panel on LCD HY32C over SPI on STM32. How to do it right?

There is a HY32C LCD display with an ads7843 touch panel controller working via SPI.
in all the examples that I found some completely different information on registers in the examples.
The datasheet also has a vague description.
Tell me what I'm doing wrong, that instead of coordinates I get some kind of nonsense?

#include "mbed.h"

Serial pc(SERIAL_TX, SERIAL_RX);
SPI panel(SPI_MOSI, SPI_MISO, SPI_SCK);
InterruptIn TP_IRQ(PB_12);

DigitalOut TP_CS(PB_6);

void tp_tap(void)
{
  unsigned short X, Y;

  panel.write(0x90);
  X = panel.write(0xFF);
  X<<=8;
  X += panel.write(0x00);
  X=X>>4;
  pc.printf("X=%d,  ", X);

  panel.write(0xD0);
  Y = panel.write(0x00);
  Y<<=8;
  Y += panel.write(0x00);
  Y=Y>>4;
  pc.printf("Y=%d\n", Y);
}


int main(){
  TP_CS=0;
  panel.format(12, 0);
  TP_IRQ.fall(&tp_tap);
  while(1){ }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dixi_Alex, 2014-09-21
@Dixi_Alex

It seems to me that I understood approximately how it works - ads7843 is practically an ADC that outputs voltage values ​​via SPI on two resistive dividers in 12-bit format.
That is, the output value is not the coordinates, as I thought, but the values ​​of the digitized voltage at the point of pressing, which must be converted into coordinate values ​​on the LCD.
Correct me if I'm wrong, please.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question