Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question