| peekay123
|
Problems polling touch with SPIPosted at:2016-09-16 12:06:25
|
|
I gave up on using I2C and switched to the (software) SPI interface provided by Digole in both the old and new libraries. The code in both libraries is idential so library version is not a factor. The display is a 2015 v3.0 unit. I poll the display for touch with the following (partial) code running in a loop that contains a 5ms delay between loops: writeStr("RPNXYI");
touch_x = display.read1();
touch_x <<= 8;
touch_x += display.read1();
touch_y = display.read1();
touch_y <<= 8;
touch_y += display.read1();
... code to check for button push...
This works well for a few minutes until one of the display.read1() calls hangs. More specifically, it hangs in the Digole SPI library code as indicated:
digitalWrite(_SSpin, HIGH);
digitalWrite(_SSpin, HIGH);
while (digitalRead(_SIpin) == LOW); //check to see the data is ready(1) or not(0)
digitalWrite(_SSpin, LOW); //tell display module I will read data
digitalWrite(_SSpin, LOW); //delay about 5us to wait module prepare data
digitalWrite(_SSpin, LOW);
Why is this line required and under what conditions would the _SIpin not go LOW?
Is it possible to use hardware SPI instead of the bit-banged version?
I know that I can use PENIRQ to poll for touch. However, I would like to get a clear understanding of how SPI works and why software polling hangs.
Thanks!
|
