[Urgent Help] I'm lost... What "memory address" am I accessing on the XPT2046 to read coordinates? (My professor's question stumped me)

Hello, amazing people of the Arduino community.

I'm a student currently working on a project with an Arduino and an XPT2046 touchscreen controller. After days of poring over the datasheet, I thought I finally understood it. I concluded that to read the X-coordinate, I needed to send the control byte 0xD0 via SPI.

Feeling confident, I explained this to my professor: "To get the X-coordinate, we send the command 0xD0!" But his response caught me completely off guard.

"Okay, so which memory address are you accessing?"

My mind went blank. I always assumed the XPT2046 performs an ADC conversion, stores the result in an internal register, and that we simply send a "command" to clock out that data sequentially. A memory address? It felt like there was a massive hole in my understanding, and honestly, I'm still not sure if my initial concept was right or what I'm missing.

I'm hoping the experts here can shed some light on my confusion.

Here are my specific questions:

  1. What exactly did my professor mean by a "memory address"? In the XPT2046 datasheet, I see command bytes like 0xD0, but I can't find anything about accessing specific, addressable memory locations like you would with RAM. Am I misunderstanding the concept of an "address" in this context? Or do the bits within the command byte itself act as a form of "channel address"?
  2. How does the XPT2046 actually store the coordinate value? Is my assumption correct that it uses temporary, non-addressable internal registers? If so, is the act of sending 0xD0 via SPI essentially a command that means, "Please read the ADC value for the X-axis channel, place it in your register, and prepare to send it back to me"?
  3. (A more fundamental question) What about devices that don't have registers? I know not all peripherals are controlled via memory-mapped addresses. For devices like the XPT2046 that seem to be command-driven without explicit "addresses," what does their data handling architecture typically look like? Is there a specific term for this type of interface or device?

Thank you for taking the time to read through my long and confused post. Any hint or piece of wisdom you could share would be a lifeline to pull me out of this pit of confusion. I would be incredibly grateful for your help.

Have your instructor take a look a the the XPT2046 data sheet.

The device does not appear to have memory registers accessible to the data transfer protocol. It appears to be a state machine, implemented in a custom controller, possibly a programmable gate array. Or just an ASIC (special purpose IC).

1 Like
  1. No idea what the prof meant, ask him. Address can indeed mean different things.
  2. I haven't worked with or read the datasheet recently so I don't have an answer.
  3. First time I am hearing this.

I think you need to talk to your prof.

1 Like

0xD0 is 11010000 binary. Bit 7 is the start bit and bits 6, 5, 4 are the ADC MUX "address" of the X position so "101" is the address your prof is looking for.

Tables 4, 5, 6 on the data sheet are the references you need.

1 Like

Thank you so much for taking the time to explain this so thoroughly. Your help has been invaluable.

I really appreciate your detailed explanations. You've been a massive help, and everything is much clearer to me now.

2 Likes

Thank you for your kindness. This was incredibly helpful!

It may also help to look at an Arduino library which interprets the XPT2046 resistive touch screen controller: GitHub - PaulStoffregen/XPT2046_Touchscreen: Touchscreen Arduino Library for XPT2046 Touch Controller Chip .

That is more or less how I understand it works.
There is an internal shift register (it looks like 16 bits) into which your 8 bit commands land and the 12 bit results from the ADC land.
In 16 cycles, your 8 bit command is sent together with 8 dummy bits and the result that is returned is 12 bits from the previous ADC result and 4 dummy bits.

You have to then convert these returned voltages to coordinates and pen pressure.

2 Likes

very thank you for your advice!!