FTDI Community
General Category => General Discussion => Topic started by: pravin on September 15, 2018, 10:53:04 AM
-
Hi , i bought FT812 display few days before and wants to communicate with over SPI. I am using freescale MK22FX512VLL12 controller.
I am not able to read chip id( 0x7c ).Always getting 0 in RX Buffer
Please help me to work this,
I am referring FT800 sample code and i have also changed REG_ADD according to FT81XX DATASHEET
My code is:
SpiHostCommand(FT_GPU_EXTERNAL_OSC);
Delay(1);
SpiHostCommand(FT_GPU_ACTIVE_M);
Delay(1);
SpiHostCommand(FT_GPU_PLL_48M); // Ensure configured to 48 MHz
Delay(1);
SpiHostCommand(FT_GPU_CORE_RESET); // Reset the core
Delay(1);
SpiHostCommand(FT_GPU_ACTIVE_M);
Delay(1);
chipid = 0x00; // Read the Chip ID to check comms with the FT800 - should be 0x7C
while(chipid != 0x7C){
SpiSendAddresstoLcd(REG_ID); // REG_ID 302000h
chipid = SpiReadLcd(); // Read the actual value
}
void SpiHostCommand(unsigned char HostCommand)
{
unsigned char SentData;
PORT_LCD_CS1B &= ~GPIO_PDOR_PDO(GPIO_PIN(LCD_CS1B));
SentData=(HostCommand & 0x3F | 0x40 );
SPI_Send_byteToLcd(SentData);
SentData=0x00;
SPI_Send_byteToLcd(SentData);
SentData=0x00;
SPI_Send_byteToLcd(SentData);
PORT_LCD_CS1B |= GPIO_PDOR_PDO(GPIO_PIN(LCD_CS1B));
}
void SpiSendAddresstoLcd(unsigned long Memory_Address)///read data from memory address
{
unsigned char SPI_Writebyte;
PORT_LCD_CS1B &= ~GPIO_PDOR_PDO(GPIO_PIN(LCD_CS1B));
SPI_Writebyte = ((Memory_Address & 0x00FF0000) >> 16); // Mask off the first byte to send
SPI_Writebyte = (SPI_Writebyte & 0x3F); // Since this is a read, the upper two bits are forced to 00
SPI_Send_byteToLcd(SPI_Writebyte); // Call the low-level SPI routine for this MCU to send this byte
SPI_Writebyte = ((Memory_Address & 0x0000FF00) >> 8); // Mask off the next byte to be sent
SPI_Send_byteToLcd(SPI_Writebyte); // Call the low-level SPI routine for this MCU to send this byte
SPI_Writebyte = (Memory_Address & 0x000000FF); // Mask off the next byte to be sent (least significant byte)
SPI_Send_byteToLcd(SPI_Writebyte); // Call the low-level SPI routine for this MCU to send this byte
// Send dummy 00 as required in the FT800 datasheet when doing a read
SPI_Writebyte = 0x00; // Write dummy byte of 0
SPI_Send_byteToLcd(SPI_Writebyte); //
}
unsigned char SpiReadLcd()
{
unsigned char Data=0x00;
Data=SPI_Receive_byteFromLcd();
PORT_LCD_CS1B |= GPIO_PDOR_PDO(GPIO_PIN(LCD_CS1B));
return Data;
}
-
Hello,
The following start-up sequence should be used with the FT81X, please note the 500ms delay at start-up:
MCU_PDlow(); // PD low to reset device
MCU_Delay_20ms();
MCU_PDhigh(); // PD high again
MCU_Delay_20ms();
// ---------------------- Optional clock configuration ---------------------
// Un-comment this line if using external crystal. Leave commented if using internal oscillator.
// Note that most FTDI/BRT modules based on FT800/FT801 use an external crystal
// EVE_CmdWrite(0x44, 0x00); // 0x44 = HostCMD_CLKEXT
// You can also send the host command to set the PLL here if you want to change it from the default
// of 48MHz (FT80x) or 60MHz (FT81x)
// The command would be called here before the Active command wakes up the device
// ---------- Wake FT8xx and delay to allow device to start-up -------------
EVE_CmdWrite(FT81x_ACTIVE, 0x00); // Sends 00 00 00 to wake FT8xx
MCU_Delay_500ms(); // 500ms delay (EVE requires at least 300ms here))
// --------------- Check that FT8xx ready and SPI comms OK -----------------
while (EVE_MemRead8(REG_ID) != 0x7C) // Read REG_ID register (0x302000) until reads 0x7C
{
}
while (EVE_MemRead8(REG_CPURESET) != 0x00) // Ensure CPUreset register reads 0 and so FT8xx is ready
{
}
// ------------------------- Display settings ------------------------------
// WQVGA display parameters
lcdWidth = 800; // Active width of LCD display
lcdHeight = 480; // Active height of LCD display
lcdHcycle = 928; // Total number of clocks per line
lcdHoffset = 88; // Start of active line
lcdHsync0 = 0; // Start of horizontal sync pulse
lcdHsync1 = 48; // End of horizontal sync pulse
lcdVcycle = 525; // Total number of lines per screen
lcdVoffset = 32; // Start of active screen
lcdVsync0 = 0; // Start of vertical sync pulse
lcdVsync1 = 3; // End of vertical sync pulse
lcdPclk = 2; // Pixel Clock
lcdSwizzle = 0; // Define RGB output pins
lcdPclkpol = 1; // Define active edge of PCLK
EVE_MemWrite16(REG_HSIZE, lcdWidth);
EVE_MemWrite16(REG_HCYCLE, lcdHcycle);
EVE_MemWrite16(REG_HOFFSET, lcdHoffset);
EVE_MemWrite16(REG_HSYNC0, lcdHsync0);
EVE_MemWrite16(REG_HSYNC1, lcdHsync1);
EVE_MemWrite16(REG_VSIZE, lcdHeight);
EVE_MemWrite16(REG_VCYCLE, lcdVcycle);
EVE_MemWrite16(REG_VOFFSET, lcdVoffset);
EVE_MemWrite16(REG_VSYNC0, lcdVsync0);
EVE_MemWrite16(REG_VSYNC1, lcdVsync1);
EVE_MemWrite8(REG_SWIZZLE, lcdSwizzle);
EVE_MemWrite8(REG_PCLK_POL, lcdPclkpol);
FT81x_GPIO = EVE_MemRead8(REG_GPIO); // Read the GPIO register for a read/modify/write operation
FT81x_GPIO = FT81x_GPIO | 0x80; // set bit 7 of GPIO register (DISP) - others are inputs
EVE_MemWrite8(REG_GPIO, FT81x_GPIO); // Enable the DISP signal to the LCD panel
// Can move these 2 lines to after the first display list to make the start-up appear cleaner to the user
EVE_MemWrite8(REG_PCLK, lcdPclk); // Now start clocking data to the LCD panel
EVE_MemWrite8(REG_PWM_DUTY, 127);
// ---------------------- Touch and Audio settings -------------------------
EVE_MemWrite16(REG_TOUCH_RZTHRESH, 1200); // Eliminate any false touches
EVE_MemWrite8(REG_VOL_PB, ZERO); // turn recorded audio volume down
EVE_MemWrite8(REG_VOL_SOUND, ZERO); // turn synthesizer volume down
EVE_MemWrite16(REG_SOUND, 0x6000); // set synthesizer to mute
// ----------------- First Display List to clear screen --------------------
ramDisplayList = RAM_DL; // start of Display List
EVE_MemWrite32(ramDisplayList, 0x02000000); // Clear Color RGB sets the colour to clear screen to black
ramDisplayList += 4; // point to next location
EVE_MemWrite32(ramDisplayList, (0x26000000 | 0x00000007)); // Clear 00100110 -------- -------- -----CST (C/S/T define which parameters to clear)
ramDisplayList += 4; // point to next location
EVE_MemWrite32(ramDisplayList, 0x00000000); // DISPLAY command 00000000 00000000 00000000 00000000 (end of display list)
EVE_MemWrite32(REG_DLSWAP, DLSWAP_FRAME); // Swap display list to make the edited one active
Please note that the Freescale samples are for the FT800 and not the FT81X, as such you should ensure you have the correct header files in your project. You can find the updated header files in our main SampleApp at the following:
https://www.ftdichip.com/Support/SoftwareExamples/FT800_Projects.htm (https://www.ftdichip.com/Support/SoftwareExamples/FT800_Projects.htm)
Best Regards,
FTDI Community
-
Thanks for reply,
Now, I am able to read chip id from FT81x. But Back light is not turning ON ; before it was turning ON during making PD_PIN as a OUTPUT then set to LOW.
can you please explain what is the condition to make Back light turn ON.
It will help me to understand the Display functionality
I have also tried an example of FTDI to display screen But fails to do that.
Please help,
My code:
void ApplicationScreen1()
{
ramDisplayList=RAM_DL+0;
FT800_SPI_SendAddressWR(ramDisplayList); // Write first entry in Display List (first location in DL Ram)
FT800_SPI_Write32(0x02000000); // Clear Color RGB 00000010 BBBBBBBB GGGGGGGG RRRRRRRR (B/G/R = Colour values)
// Clear the Colour, Stencil and Tag buffers. This will set the screen to the 'clear' colour set above.
ramDisplayList +=4;
FT800_SPI_SendAddressWR(ramDisplayList); // Write next entry in display list (each command is 4 bytes)
FT800_SPI_Write32(BEGIN(BITMAPS)); // Clear 00100110 -------- -------- -----CST (C/S/T define which parameters to clear)
ramDisplayList +=4;
FT800_SPI_SendAddressWR(ramDisplayList);
FT800_SPI_Write32(VERTEX2II(220,110,31,'F'));
ramDisplayList +=4;
FT800_SPI_SendAddressWR(ramDisplayList);
FT800_SPI_Write32(VERTEX2II(220,110,31,'T'));
ramDisplayList +=4;
FT800_SPI_SendAddressWR(ramDisplayList);
FT800_SPI_Write32(VERTEX2II(220,110,31,'D'));
ramDisplayList +=4;
FT800_SPI_SendAddressWR(ramDisplayList);
FT800_SPI_Write32(VERTEX2II(220,110,31,'I'));
ramDisplayList +=4;
FT800_SPI_SendAddressWR(ramDisplayList);
FT800_SPI_Write32(ENDP());
ramDisplayList +=4;
FT800_SPI_SendAddressWR(ramDisplayList);
FT800_SPI_Write32(COLOR_RGB(160,22,22)); //SET COLOUR TO RED
ramDisplayList +=4;
FT800_SPI_SendAddressWR(ramDisplayList);
FT800_SPI_Write32(POINT_SIZE(320)); //SET POINT SIZE TO 20 PIXELS IN RADIUS
ramDisplayList +=4;
FT800_SPI_SendAddressWR(ramDisplayList);
FT800_SPI_Write32(BEGIN(FTPOINTS)); //START DRAWING POINTS
ramDisplayList +=4;
FT800_SPI_SendAddressWR(ramDisplayList);
FT800_SPI_Write32(VERTEX2II(192,133,0,0));//RED COLOUR
ramDisplayList +=4;
FT800_SPI_SendAddressWR(ramDisplayList);
FT800_SPI_Write32(ENDP());
ramDisplayList +=4;
FT800_SPI_SendAddressWR(ramDisplayList);
FT800_SPI_Write32(DISPLAY());//display image
FT800_SPI_SendAddressWR(REG_DLSWAP); // Writing to the DL_SWAP register...value 10 means render after last frame complete
FT800_SPI_Write32(0x00000002); // 00000000 00000000 00000000 000000SS (SS bits define when render occurs)
}
-
Hello,
The backlight is controlled by the following registers:
Depending on which module you are using you may also need to toggle an GPIO pin to enable the displays backlight.
Best Regards,
FTDI Community
-
Hello...I used this kind of connection to emulate a long cable with some disturbs, because the final machine should have the display fixed on cover of openable electric box and the electronic device fixed inside the box, with a 20-30cm cable.
pcb assembly canada (https://www.7pcb.com/PCB-Assembly-Canada.php)