Data pins vs control pins and MEGA 2560

As a relative newcomer to programming and using libraries, I am repeated stumped in trying to understand the purpose of pin assignment when attaching a 3.2" LCD TFT to the Mega 2560 board.

Data pins seem to be assigned along the lines of pins 22-29 but the order is not clear regarding assignment.

Then to top it off, there appear to be repeatedly assigned some sort of control pin arrangement along the lines of MyGLCD(Controller_Name, a,b,c,d) where a, b, c and d are 38, 39, 40 and 41 respectively.

First of all, what is the order control a, b, c, and d talking about? If it is SDCS, CLK,MISO and MOSI, what order are they in? Also, given the pin identification for MEGA 2560, why are pins 50-53 not chosen? I remain confused and cannot get my screen to work.

Thanks for the enlightenment. :slight_smile:

It looks like you are using the UTFT library. It comes with documentation in a PDF file.
This explains the arguments for the constructor().

The UTFT and UTouch libraries never use the hardware SPI even for SPI TFT controllers.
However, the SD library always uses hardware SPI for the disk.

This explains why they use so many different pins. Because they bit-bash TFT and UTouch, they use separate pins.

If you are using a popular display and adapter shield, there is probably an existing name and example. Hence the arguments in the constructor().

David.

It would be helpful to know WHAT display, and WHAT UTFT constructors you have tried.

The (xxxxx, 38,39,40,41) refers to (model, RS, WR, CS, RST).

Indeed pins 50-53 are used for the SD card generally, and refer respectively to MISO, MOSI, SCK and SS. You might like to look at a pinout diagram of the MEGA HERE.

The best shield is made by Coldtears Electronics(CTE) (not the Sainsmart bastardised version!!) and the assignments go like this :-

Pin 22 DB8
Pin 23 DB9
Pin 24 DB10
Pin 25 DB11
Pin 26 DB12
Pin 27 DB13
Pin 28 DB14
Pin 29 DB15
Pin 30 DB7
Pin 31 DB6
Pin 32 DB5
Pin 33 DB4
Pin 34 DB3
Pin 35 DB2
Pin 36 DB1
Pin 37 DB0
Pin 38 RS
Pin 39 WR
Pin 40 CS
Pin 41 RST
Pin 42 Free for user
Pin 43 Free for user
Pin 44 PWM
Pin 45 Flash_CS
Pin 46 Free for user
Pin 47 Flash CS
Pin 48 Free for user
Pin 49 Free for user
Pin 50 MISO
Pin 51 MOSI
Pin 52 CLK
Pin 53 SD_CS

Hope this helps!

Regards,

Graham

PS.... Consider the MEGA is 5V and all of your data signals need translating to 3.3V, which is where the benefit of an ACTUAL shield comes in useful..... Many shield suppliers use resistors, but CTE use actual translator chips..... as do elecfreaks in fairness....