News:

Let's find out together what makes a PIC Tick!

Main Menu

Difficulty with Touchscreen

Started by PaulF, Oct 30, 2026, 09:32 AM

Previous topic - Next topic

PaulF

I have made quite a few successful circuits with TFT touchscreens, however I am having great difficulty getting a touchscreen to work on a new board.
I am using a PIC18F47K40.
The display works fine and I have tried everything I can think of however the touchscreen refuses to work.
I have a similar board with a PIC18F67K22 & the same touchscreen with the same Firmware (with corresponding config etc for the PIC) works fine on that. The only other difference between the boards is the PIC18F67K22 is using an external oscillator but the PIC18F47K40 uses internal.
I have monitored all the touchscreen pins on a scope & everything looks identical on both when the screen is touched, with the exception of the T_DO(MISO) pin on the PIC18F47K40 which is permanently low.
The simple program with only the display and touchscreen gives a readout on the display when the T_IRQ is detected, to show wTftTouchX, Y & Z from "TftTouchScreenReadValues() which remain 0 (with the exception of Z which is 0289) on the PIC18F47K40 board, but change with each touch on the other board.
The touchscreen pins are all on their own micro pins & I have tried on different ports etc which don't have PPS just in case that was the issue & have checked all connections etc but the problem still persists.

I am almost at the point of admitting defeat with this particular micro but maybe I can't see the wood for the trees, can anyone who understands how this all works better that me, give me any pointers as to where to look?

trastikata

Hi,

can you first try a simple test to see if the MISO input pin on this particular micro works as expected. If you have a LED or some other way to indicate a High-Low state, use a small resistor or wire to set the MISO pin High and Low and in the code just run a loop that will set or clear the indicator when you touch the MISO pin with the wire.

If the MISO pin works, then some things to try:

- MCU clock speed - is it the same? The touch code uses software delays, in the latest update I revised the delays, you can try that first.

- If the MOSI line is giving the same code on the scope as the other micro and the MISO line is not responding to this particular MCU, it could be that the wave shape is not clean enough for the touch controller, then you can try adjusting the delays in XPT2046.inc even a bit further.

tumbleweed

Also, if using PPS make sure the pin used for MISO is set as an input, disable any analog mode for the pin, and set the PPS for the SPICLK for both output and input assignments

▲