502
« on: May 11, 2020, 02:52:07 PM »
Hello,
We recommend to read the REG_ID to ensure the FT813 is ready and it is also a good way to ensure the SPI communications are working.
Here is a basic start-up flow. Initially, if you try the parts in red text and ensure that you get the 0x7C back and that REG_CPU_RESET goes to 0 then this will give a good indication that the communication is working.
If your code gets stuck at the REG_ID read, could you post or send us a logic analyser waveform of all your SPI lines
Best Regards, FTDI Community
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 with no access over SPI during delay
// --------------- 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
// ---------------------- 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
EVE_MemWrite8(REG_PCLK, lcdPclk); // Now start clocking data to the LCD panel
EVE_MemWrite8(REG_PWM_DUTY, 127);
}