Sunday, June 4, 2023

More complications of the nonstandard pretend SPI used with the LCD Module

WORD FRAME SIZE AND SLAVE SELECT FOR LCD CONTROLLER

As previously reported, communicating with the LCD controller chip required words of 16 bits, so that the SPI master on my board does not drop slave select until the end of that transfer. Some transfers to the LCD controller involve multiple 16 bit words, which it appears would work properly even with slave select toggled between words. However, this is not absolutely certain. 

TOUCH CONTROLLER WORD FRAME SIZE AND SLAVE SELECT

The touch controller chip requires frames of 24 bits under a single activation of the slave select to that chip. The SPI master on my board will toggle slave select after the first 16 and then send a full additional 16 bits as a second transaction. Thus the current setting I have for SPI will NOT work properly with the touch controller. 

Further, there is no configuration option for 24 bit words. I would need to instead revert to the kludge where I select SPI mode 2 instead of the actual mode 0, then invert the clock to allow the touch controller on mode 0 to communicate with the master on mode 2. With word size set to 8 bits, this will allow me to send multiples of 8 bits. 

The only advantage of this is that it removes the automatic drop of slave select after each word frame. Instead, slave select will go low when the word is complete and the transmit FIFO has no more words to send. Thus if I push three bytes into the FIFO we get a 24 bit transmission under one slave select, while if I push two bytes in the FIFO I get a 16 bit transmission in a single slave select. I could even handle the mode where multiple 16 bit words are sent without dropping slave select in between. 

A second option is to use the second SPI master on my board to communicate with the touch controller while the original one speaks only to the LCD controller. This has the difficulty that I will be sharing one set of wires for SCLK, MOSI and MISO which won't work well. Had I the ability to direct wire a separate clock and data lines to the touch controller, this would have been okay.

A third option, assuming we do the kludge with inverted clock for SPI mode 2, is that I can stop and reconfigure the SPI master each time I switch between LCD and touch controller - set 16 bit words for the LCD controller and 8 bit words for the touch pad. In that way I could also implement the different speeds that the demo code had implemented, using 2.5MHz for the touch controller and 20MHz for the LCD controller communications. 

I frankly am not sure how this is supposed to work properly on Arduino, which is listed as a secondary microcontroller to drive the LCD module. Perhaps the do bit banging or some other atrocity in the Arduino side library to overcome these oddities in the implementation. 

Time for me to cogitate, in addition to regretting the day that I selected and bought this LCD Module for the project based on vague marketplace statements that it uses SPI and came with example code. 

No comments:

Post a Comment