DUE and Sainsmart 7" LCD Touch Not Working fear ISR

I have a SainSmart 7" LCD Touch kit with DUE. I includes the CTE TFT LCD/SD Shield for Arduino Due. The LCD part works fine but the touch screen demo Utouch_Calibration.ino freezes .

To troubleshoot this I poured over this forum looking for similar problems but did not find any. I then proceeded to copy the code from the Utouch_Calibration.ino line by line into the working UTFT_Demo_800x480.ino when I include the first real line of code line:

UTouch myTouch( 6, 5, 4, 3, 2);

The program breaks. What ever was up on the LCD from the last run of the Demo is stuck there. I suspect that the program is banging away in a ISR and never gets out. Here is the code fragment:

// UTFT_Demo_800x480 (C)2013 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// This program is a demo of how to use most of the functions
// of the library with a supported display modules.
//
// This demo was made for modules with a screen resolution 
// of 800x480 pixels.
//
// This program requires the UTFT library.
//

#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
UTFT myGLCD(CTE70,25,26,27,28);   // Remember to change the model parameter to suit your display module!

#include </Users/Kurt/Documents/Arduino/libraries/UTFT_7/DUE/touch/UTouch/UTouch.h>

// Define the orientation of the touch screen. Further 
// information can be found in the instructions.
#define TOUCH_ORIENTATION  PORTRAIT
UTouch  myTouch( 6, 5, 4, 3, 2);

// ************************************
// DO NOT EDIT ANYTHING BELOW THIS LINE
// ************************************

// Declare which fonts we will be using
extern uint8_t SmallFont[];

uint32_t cx, cy;
uint32_t rx[8], ry[8];
uint32_t clx, crx, cty, cby;
float px, py;
int dispx, dispy, text_y_center;
uint32_t calx, caly, cals;
char buf[13];




void setup()
{
  randomSeed(analogRead(0));
  
// Setup the LCD
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
}

void loop()
{
  int buf[798];
  int x, x2;
  int y, y2;
  int r;

// Clear the screen and draw the frame
  myGLCD.clrScr();
  myGLCD.setFont(SmallFont);


  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 799, 13);
  myGLCD.setColor(64, 64, 64);
  myGLCD.fillRect(0, 466, 799, 479);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.print("* Universal Color TFT Display Library *", CENTER, 1);
  myGLCD.setBackColor(64, 64, 64);
  myGLCD.setColor(255,255,0);
  myGLCD.print("<http://electronics.henningkarlsen.com>", CENTER, 467);

Thanks

Kurt

Hi Kurt,

From the genuine CTE DUE_Shield_readme.txt :-

CTE TFT/SD shield for arduino DUE
coldtears electronics
http://www.coldtears.com/electronics

This shield is created for arduino DUE, which fit two types of LCD:

  1. 40pin version LCD which is commonly used in previous version of TFT Mega shield for Arduino MEGA 2560
  2. 32pin version LCD which is commonly used in STM32 development board.

There is a SD slot and a Font IC (SPI flash) footprint, for upgrade to include Font IC to draw text to the LCD. These two features are created to support LCD modules which do not have SD slot or font IC.

To use with UTFT library:

1.uncomment "#define CTE_DUE_SHIELD 1" in the HW_ARM_defines.h in the \hardware\arm folder of the UTFT library

2.Change the pinout to : UTFT myGLCD(CTE50,25,26,27,28);


Using the Touch function:

Remember to change the touch initialization to the following if it does not work.
The TP DataIN is routed to pin 32 of arduino DUE instead of 4.
(Because pin4 of arduino is a hardware SPI CS pin, which is reserved for SPI device)


Shipping default jumper configuration:

The TFT/SD Shield for arduino DUE is shipped with the following jumper config, if you use TFT modules in our store, you do not need to reconfig the jumpers.

LCD Vcc - 3.3V (JP2 shorted)
LCD backlight (LEDA+) - 3.3V (JP4 shorted)
arduino Pin32 to TP_DIN (JP10 opened)
On board SD - disabled (JP8 opened)

Suggest try UTouch myTouch(6, 5, 32, 3, 2)

Regards,

Graham

I have just answered this point in the other post you posted the wrong solution you proposed.

#include </Users/Kurt/Documents/Arduino/libraries/UTFT_7/DUE/touch/UTouch/UTouch.h>

You have a hell of a convoluted library structure there! Presumably destroyed by sainsmart?

That is NOT the way to do it!

The GENUINE Henning Karlsen libraries should be located DIRECTLY in the arduino/libraries folder like this :-

arduino/libraries/UTFT
arduino/libraries/UTFT_Buttons
arduino/libraries/UTOUCH
arduino/libraries/tinyFAT
arduino/libraries/UTFT_tinyFAT

Use the genuine libraries, locate them in the correct location, include them correctly using

#include <UTouch.h>
#include <UTFT.h>
#include <UTFT_Buttons.h>

Don't bodge it, then complain something doesn't work!

Regards,

Graham

Thanks Graham!

So I was not happy having to put the path in the file like I did but the Utouch.h was not automatically located. I am not sure why. SainSmart sent me a link to the libraries which I downloaded and zipped. I then used the import library to import the zip file into the Arduino tool. It put the files in /Users/Kurt/Documents/Arduino/libraries. When I installed the toolset I put the Arduino directory in my user directory at /Users/Kurt/Documents. Did I do something wrong here?

BTW I made the modifications in the files specifcally the UTouch myTouch(6, 5, 32, 3, 2); and verified that the #define CTE_DUE_SHIELD 1 was in the header although I needed to add that file HW_ARM_defines.h as the file in Macintosh HD ▸ Users ▸ Kurt ▸ Documents ▸ Arduino ▸ libraries ▸ UTFT_7 ▸ DUE ▸ touch ▸ UTouch ▸ hardware ▸ arm looked like this:

// *** Hardwarespecific defines ***
#define cbi(reg, bitmask) *reg &= ~bitmask
#define sbi(reg, bitmask) *reg |= bitmask
#define rbi(reg, bitmask) ((*reg) & bitmask)

#define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask);
#define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask);

#define swap(type, i, j) {type t = i; i = j; j = t;}

#if defined(TEENSYDUINO) && TEENSYDUINO >= 117
  #define regtype volatile uint8_t
  #define regsize uint8_t
#else
  #define regtype volatile uint32_t
  #define regsize uint32_t
#endif
#define CTE_DUE_SHIELD 1

I also verified the jumpers and found that the shield SainSmart shipped has JP10 shorted not opened.
The bad behavior remains the same.

I was using the UTFT_7 lib that SainSmart supplied as I assumed they had it properly configured. This might not be the case.

Thanks

Kurt

/users/name/documents/arduino/libraries is all fine. I would suggest you delete the UTFT_7 folder and contents and get the real libraries from Henning. Put them where I have told you, make the changes you are now aware of.

I checked my shield, my JP10 was shorted when I got it, I had problems so opened it. Now my tp_din is DEFINITELY 32, as it should be.

Don't forget to restart the IDE after changing libraries!

Post back your results.

Regards,

Graham

Edit: Utouch was not automatically picked up, not sure why???? Why is because of 20 levels of unnecessary folder structure!!

Edit 2: You incorrectly modified hw_arm_defines.h!! when you got the real libraries in the real locations..............let me know

Graham

Thank you so much for taking your time to help with this problem. I deleted all of the UTFT stuff that I downloaded from SainSmart and installed the current code. I made no changes to the jumpers and used the following declarations:

UTFT myGLCD(CTE70,25,26,27,28);
UTouch myTouch( 6, 5, 4, 3, 2);

I also uncommented #define CTE_DUE_SHIELD 1 in the HW_ARM_defines.h

All is working now!!

Thanks

Kurt