I am attempting to drive a 320x240 colour TFT screen, which I believe is a type SPFD5408, and it is already
mounted as a UNO shield. See this:-
When power is applied to the UNO,the screen backlight is illuminated. The illumination is constant but
the display varies cyclically from what is probably white, to black. I have downloaded the files:-
UTFT_Demo_320x249.ino
DefaultFonts.c
UTFT.h
From the Henning Karlsen TFT web site Copyright (C)2010-2013 .
The files appear to in the correct place. When I originally tried to compile, I had the PROGMEN
error message. I have modified UTFT_Demo_320x240.ino in 2 places. The 1st adds the line #include <avr/pgmspace.h> at the beggining. I have uncommented the line for
Arduino 2009/Uno in the sketch , and altered it to read:-
UTFT myGLCD(SPFD5408A,21,20,19,18);
The numbers are suspect, I counted clockwise around the shield pins to get the numbers
corresponding to RS WR CS RST. There seems to be no actual number system. If there is,
where do you start counting from?.
I also modified 'DefaultFonts.c' by adding 'const' to the beggining of the 3 lines
containing 'PROGMEM'. The sketch now compiles and uploads with no error. After the
upload, I hold down the reset switch on the display for a couple of seconds. There are
no graphics, just a mid grey colour. When the reset is pressed, the backlight intensity
varies before settling down to a mid grey colour.
The UNO works ok flashing LEDs. The screen/shield is new. The shield makes connection
to the UNO pins:-
Digital D0 - D13, GND, AREF, and to Analogue IA4 -IA0,GND,+5V,3.3V
I am a newbie. This is my first Arduino project. I am experienced in AVR assembly,
and have a small amount of C experience.
The pin numbers can be found on the Arduino silkscreen: 0-13 on one edge and A0-A5 on the other.
The advertisement for the shield says "Uses digital pins 5-13 and analog 0-3." but the silkscreen on the shield shows connections to pins 2-13 and analog A0-A4. I would guess that the silkscreen is more accurate:
Thank you Johnwasser. I suspect that I pass the wrong numbers in the line within the demo program. The
line is:-
UTFT myGLCD(SPFD5408A,21,20,19,18);
Where do I get the bumbers from? I agree, as you say, that
A0 -> LCD_RD
A1 -> LCD_RW
A2-> LCD_RS
A3 -> LCD_CS
A4 -> LCD_RST
but what numbers do I place in the statement above to replace the 21,20,19,18. ?
I would have expected the file UTFT.h to have taken care of this.
Thank you Karma. It didn't work, but thanks for the 'steer' that I can enter other things
rather than pure numbers.
As the silk screen on my shield has the functions RD WR etc marked, I used the line:-
This is somewhat more successfull, in that there are now graphics on the screen, and
the background is light blue shading to green in two places. The graphics are thin lines,
looking unlike any demos that I have seen, but we slowly make progress. Thanks.
When you say it did not work, you make it sound as though it compiled and downloaded to UNO flash and then all you had was a white screen. I suspect it did not compile since the compiler should barf on the driver type of SPFD5408A since that type is not defined within UTFT. No matter since the problem lies a bit deeper...
The shield does NOT conform to the pinouts that UTFT uses.
Specifically, the 8 data bits (LCD_D0-7) used by the shield are spread across two ports, 2 bits on port B and 6 bits on port D. This was done to prevent the loss of the serial terminal in the Arduino IDE since the UART used for this functionality needs digital output pins 2 and 3 which correspond to port D, bits 0 and 1. If you cut some traces and re-wired LCD_00 and _01 to digital pins 2 & 3 you'd then have all eight LCD data lines connected to UNO port D - and UTFT would be happy and it would function unchanged since that is the configuration that UTFT expects.
On the up side, UTFT is very well structured and the changes that need to be made are all in one file, \hardware\avr\HW_ATmega328P.h.
The following sections need changes: LCD_Writ_Bus within the "case 8" section were only port D is written to. You need to wiggle bits and write 2 bits to port B and 6 to port D. Then, the "_set_direction_registers" area to add the two port B bits. Finally, the _fast_fill_16 and _fast_fill_8 subroutines need the same bit twiddles as done in LCD_Writ_Bus.
Oh, one last thing, The LCD drive type needs to be changed to one that UTFT understands. The most likely types that should work would be either ILI9325C or ILI9325D_8.
Finally, you might find a modified and working version of UTFT here: Touch Screen Shield for Arduino UNO – misc.ws I don't know for sure, it was something I found on ebay from sellers of similar LCD's as their demo code.
Thank you again Karma. You confirm what I suspected concerning data pins. It would be logical to expect d0-d7 to be used.
Re-
When you say it did not work, you make it sound as though it compiled and downloaded to UNO flash and then all you had was a white screen. I suspect it did not compile since the compiler should barf on the driver type of SPFD5408A since that type is not defined within UTFT. No matter since the problem lies a bit deeper...
I used the version of UTFT 2013 as this has entries for SPFD5408A/B. The later UTFT 2014 does not.
After the PROGMEM fix, there is no complaint from the Arduino 1.5.7. compiler. The screen display is as I would expect with
an address problem. The lines are staircase type, with missing bits. I assumed that the routines in HFTF like 'draw a line' would call on a primitive proceedure held within a SPFD5408 config file(which I have been unable to locate). I have been resigned to putting in some work with a digital scope. The easy way is to mount the shield on some plug-in breadboard, and wire link it to the UNO so I can play around with some connections. I need to do this, as I intend to use the display (eventually) with a DUE. This is much faster and has som DSP facilities. I am into SDR trancievers, and hope to use the DUE for keypar, rotary tune and other inputs, DSP processing and display + other outputs. All this will have to wait a few days however, as I am committed to other stuff for the next week. Thanks for your support. I will report back here in a while.
Best Regards 73s
I used the version of UTFT 2013 as this has entries for SPFD5408A/B. The later UTFT 2014 does not.
Then what you have is custom version because the "official" UTFT library does not drop support for a chipset once it has been added. Further, you cannot download a "2013 version" from the UTFT website so it had to come from somewhere other than Henning Karlsen's site.
I assumed that the routines in HFTF like 'draw a line' would call on a primitive proceedure held within a SPFD5408 config file(which I have been unable to locate).
Nope, it does not work that way. The drawing primitives (line, circle, rectangle, text) are all performed within UTFT. The LCD driver only provides the memory and the scanning of the pixels. What you are calling a config file are typically the initialization code streams for each driver type.
I have been resigned to putting in some work with a digital scope.
IMO, a waste of time. Your problem is software based, not hardware.
The easy way is to mount the shield on some plug-in breadboard, and wire link it to the UNO so I can play around with some connections. I need to do this, as I intend to use the display (eventually) with a DUE. This is much faster and has some DSP facilities.
If you're going to end up with a Due, start with a Due and a Due specific LCD. The 2.4" LCD you currently have expects 5 volt I/O, the Due is 3.3 volt I/O. That's what the two chips are for on the back of the LCD shield.
Also, the SAM3X8E ARM Cortex-M3 on the Due ain't no TMS320. I think you'd best research the chip a bit further if you plan on any real DSP work since the chip isn't much more than a faster AVR with some additional analog I/O and memory. Granted, it has good DMA support and IIRC some saturation maths. Of course you'll be much happier with the DUE than with a 16mhz 8-bit processor with 32kb of flash...but there is no floating point and DSP specific code. Just saying...