Interfacing NHD-3.5-320240FT-CSXP-T with NXP LPC55S69 Microcontroller
Hello,
I am new to NHD-3.5-320240FT-CSXP-T EVE2 TFT Displays. I have got the NHD-3.5-320240FT-CSXP-T display module and would like to interface it with my custom board which has the NXP LPC55S69 Microcontroller as a host.
I have gone through the github examples and datasheets. Is there any SPI driver support or reference I can follow to get started on interfacing the display to my board through the IDC Connector?
Any help on getting started on this would be much helpful.
Thanks
-
Hello,
We would recommend our Blog post about Using Gameduino 2 Library with EVE2 TFT Modules (https://newhavendisplay.com/blog/using-gameduino-2-library-with-eve2-tft-modules/) This gives a good example on how to utilize EVE2 TFT Modules and how get them working.
I will also Link the FTDI controller data sheet (https://support.newhavendisplay.com/hc/en-us/article_attachments/6963168242711).
As well as the FTDI programming guide (http://www.ftdichip.com/Support/Documents/ProgramGuides/FT81X_Series_Programmer_Guide.pdf).
You can also find more resources on page 12 of the display spec sheet (https://newhavendisplay.com/content/specs/NHD-3.5-320240FT-CSXP-T.pdf) this has a list of resources you can utilize if you do not wish to use the Gameduino 2 Library.
Regards,
0 -
Thanks for your prompt response. Since, I am using a NXP based Microcontroller (LPC55S69) as my host on the custom board, I wrote a default code in C for the interface between the host and the display. I used the FT81x programmers guide as a reference and the datasheet for the connections in my schematic.
But, once I debugged the code and executed it, I am still not getting any response on the display. I have included the code below for reference. Is there anything that I am missing as a part of the initialization sequence to boot up the display from PowerDOWN??
Kindly request you to update on this as I am new to TFT displays.
#include "fsl_spi.h"
#include "fsl_gpio.h"
#include "pin_mux.h"
#include "board.h"
#include "Eve2_81x.h"
#include "fsl_debug_console.h"
#include <stdbool.h>
#include "fsl_power.h"
// ... (definitions and prototypes)
/*********************************************************** ********************
* Definitions
*********************************************************** *******************/
#define EXAMPLE_SPI_MASTER SPI4
#define EXAMPLE_SPI_MASTER_CLK_FREQ CLOCK_GetFlexCommClkFreq(4U)
#define EXAMPLE_SPI_SSEL 3
#define EXAMPLE_SPI_SPOL kSPI_SpolActiveAllLow
#define TFT_CS_PIN 22
#define TFT_PD_PIN 31
#define FT81X_CHIP_ID 0x7C
#define CMD_READ_CHIP_ID 0x30
#define BUFFER_SIZE (64)
static uint8_t srcBuff[BUFFER_SIZE];
static uint8_t destBuff[BUFFER_SIZE];
/*********************************************************** ********************
* Prototypes
*********************************************************** *******************/
void delay(unsigned int n);
void tftSendCommand(uint8_t command);
void tftInit(void);
uint8_t spiTransfer(uint8_t data);
uint8_t readChipId(void);
void delay(unsigned int n) {
volatile unsigned int i;
for (i = 0; i < n; i++) {
// Do nothing
}
}
/*void tftSendCommand(uint8_t command) {
// Implement your code to send a command to the TFT display
// Set CS pin low
// Send command using SPI
// Set CS pin high
}*/
void tftSendCommand(uint8_t command) {
// Set CS pin low to select the TFT display
GPIO_PinWrite(GPIO, 1, TFT_CS_PIN, 0);
// Send command using SPI
spiTransfer(command);
// Set CS pin high to deselect the TFT display
GPIO_PinWrite(GPIO, 1, TFT_CS_PIN, 1);
}
void tftInit() {
// Drive PD_N pin high to power up the display
GPIO_PinWrite(GPIO, 1, TFT_PD_PIN, 1);
delay(20000); // Wait for at least 20ms
// Send CLKEXT command
tftSendCommand(0x44);
// Send ACTIVE command
tftSendCommand(0x00);
delay(300); // Wait for self-diagnosis process
// Alternatively, read REG_ID repeatedly until 0x7C is read
uint8_t chipId;
do {
chipId = readChipId();
} while (chipId != FT81X_CHIP_ID);
// Configure video timing registers and other initialization steps
// ...
// Rest of your initialization code
}
uint8_t spiTransfer(uint8_t data) {
printf("HELLo");
// Implement your code to perform SPI transfer and return received data
// ...
}
uint8_t readChipId() {
tftSendCommand(CMD_READ_CHIP_ID);
return spiTransfer(0); // Send dummy data to read chip ID
}
int main(void) {
spi_master_config_t userConfig = {0};
uint32_t srcFreq = 0;
uint32_t i = 0;
spi_transfer_t xfer = {0};
/* Set BOD VBAT level to 1.65V */
POWER_SetBodVbatLevel(kPOWER_BodVbatLevel1650mv, kPOWER_BodHystLevel50mv, false);
/* Attach 12 MHz clock to FLEXCOMM0 (debug console) */
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
/* Attach 12 MHz clock to SPI4 */
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4);
/* Reset FLEXCOMM for SPI */
RESET_PeripheralReset(kFC4_RST_SHIFT_RSTn);
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitDebugConsole();
PRINTF("\n\rMaster Start...\n\r");
SPI_MasterGetDefaultConfig(&userConfig);
srcFreq = EXAMPLE_SPI_MASTER_CLK_FREQ;
PRINTF("Frequency is:%d\n", srcFreq);
userConfig.sselNum = (spi_ssel_t)EXAMPLE_SPI_SSEL;
userConfig.sselPol = (spi_spol_t)EXAMPLE_SPI_SPOL;
SPI_MasterInit(EXAMPLE_SPI_MASTER, &userConfig, srcFreq);
/* Initialize Buffer */
for (i = 0; i < BUFFER_SIZE; i++) {
srcBuff[i] = i;
}
/* Start Transfer */
xfer.txData = srcBuff;
xfer.rxData = destBuff;
xfer.dataSize = sizeof(destBuff);
xfer.configFlags = kSPI_FrameAssert;
SPI_MasterTransferBlocking(EXAMPLE_SPI_MASTER, &xfer);
// Initialize TFT display
tftInit();
while (1) {
// Clear the display
tftSendCommand(CLEAR_COLOR_RGB(0, 0, 0));
tftSendCommand(CLEAR(1, 1, 1));
tftSendCommand(DISPLAY());
// Draw points
(POINT_SIZE(5 * 16));
(BEGIN(POINTS));
(VERTEX2F(30 * 16, 17 * 16));
(COLOR_RGB(0, 128, 0));
(POINT_SIZE(8 * 16));
(VERTEX2F(90 * 16, 17 * 16));
(COLOR_RGB(0, 0, 128));
(POINT_SIZE(10 * 16));
(VERTEX2F(30 * 16, 51 * 16));
(COLOR_RGB(128, 128, 0));
(POINT_SIZE(13 * 16));
(VERTEX2F(90 * 16, 51 * 16));
(END());
tftSendCommand(DISPLAY());
// Your application code here
// You can implement various interactions with the TFT display here
}
}0 -
Hello,
Here is some example code using an Arduino you can use as a reference.
Regards,
0
Please sign in to leave a comment.
Comments
3 comments