FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: FT813 initialization  (Read 573 times)

SpicyChef

  • Newbie
  • *
  • Posts: 5
    • View Profile
FT813 initialization
« on: May 08, 2020, 03:06:57 PM »

Hello.
I'm a total beginner here. I'm trying to initialize a 4.3" display using FT813 and an Arduino uno.
I have a shield and all the connections are good.

When I upload the code, all I can see is the backlight turning on. My goal here is to make the display bright blue "CLEAR_COLOR_RGB(0,0,255)"

Here is the code, can you tell me what is wrong and provide an example where you can? (The header file was attached)

Code: [Select]
#include <SPI.h>
#include "functions.h"






void setup() {
  // put your setup code here, to run once:
pinMode(ChipSelectPin, OUTPUT);
pinMode(INT_N, OUTPUT);
pinMode(PD_N, OUTPUT);
digitalWrite(ChipSelectPin, HIGH);   //When ChipSelectPin is high you can't communicate with FT81X
digitalWrite(INT_N, HIGH);           //deactivate interrupt to host
digitalWrite(PD_N, HIGH);            //deactivate Chip power down mode



Serial.begin(9600);

//initialise SPI
SPI.begin();
SPI.setBitOrder(MSBFIRST);          //Not strictly needed but just to be sure
SPI.setDataMode(SPI_MODE0);         //Not stirctly needed but just to be sure





}


void initialize(){
SPI.setClockDivider(SPI_CLOCK_DIV2);
host_command(CLKEXT);
host_command(ACTIVE);
delay(300);

wr16(REG_HCYCLE, 928);
wr16(REG_HOFFSET, 88);
wr16(REG_HSYNC0, 0);
wr16(REG_HSYNC1, 48);
wr16(REG_VCYCLE, 525);
wr16(REG_VOFFSET, 32);
wr16(REG_VSYNC0, 0);
wr16(REG_VSYNC1, 3);
wr8(REG_SWIZZLE, 0);
wr8(REG_PCLK_POL, 1);
wr8(REG_CSPREAD, 0);
wr16(REG_HSIZE, 480);
wr16(REG_VSIZE, 800);

//CMD_DLSTART;      //Set display list address to 0
   
    wr32(RAM_DL + 0, CLEAR_COLOR_RGB(0,0,0)); //CLEAR_COLOR_RGB0,0,0
    wr32(RAM_DL + 4, CLEAR(1,1,1));
    wr32(RAM_DL + 8, DISPLAY); //DISPLAY

    wr8(REG_DLSWAP,0x02);         //Send 0x02 because the programming guide says 10 (0x02) is recommended in most cases. Go to REG_DLSWAP for more info.
    wr8(REG_GPIO_DIR,0x80);
    wr8(REG_GPIO,0x80);
    wr8(REG_PCLK,5);

   
   
}

bool InitializeTrigger = true;               //To trigger initialization once in the beginning

void loop() {
  // put your main code here, to run repeatedly:


 
if( InitializeTrigger == true){

initialize();

InitializeTrigger = false;
}


    CMD_DLSTART;      //Set display list address to 0
   
    wr32(RAM_DL + 0, CLEAR_COLOR_RGB(0,0,255)); //CLEAR_COLOR_RGB0,0,0
    wr32(RAM_DL + 4, CLEAR(1,1,1));
    wr32(RAM_DL + 8, 0x00);
 
}
Logged

FTDI Community

  • Administrator
  • Sr. Member
  • *****
  • Posts: 443
    • View Profile
Re: FT813 initialization
« Reply #1 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);

}

Logged

SpicyChef

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: FT813 initialization
« Reply #2 on: May 12, 2020, 06:29:00 AM »

I adjusted the code to focus on reading REG_ID like you suggested but all I'm able to read is ones.

Here is my code
Code: [Select]
#include <SPI.h>
#include "functions.h"






void setup() {
  // put your setup code here, to run once:
pinMode(ChipSelectPin, OUTPUT);
pinMode(INT_N, OUTPUT);
pinMode(PD_N, OUTPUT);
digitalWrite(ChipSelectPin, HIGH);   //When ChipSelectPin is high you can't communicate with FT81X
digitalWrite(INT_N, HIGH);           //deactivate interrupt to host
digitalWrite(PD_N, HIGH);            //deactivate Chip power down mode



Serial.begin(9600);

//initialise SPI
SPI.begin();
SPI.setBitOrder(MSBFIRST);          //Not strictly needed but just to be sure
SPI.setDataMode(SPI_MODE0);         //Not stirctly needed but just to be sure



digitalWrite(PD_N, LOW);
delay(20);
digitalWrite(PD_N, HIGH);
delay(20);

SPI.setClockDivider(SPI_CLOCK_DIV4);
host_command(ACTIVE);
delay(500);
rd8(0x302000);




}

/*
void initialize(){
SPI.setClockDivider(SPI_CLOCK_DIV2);
host_command(CLKEXT);
host_command(ACTIVE);
delay(300);

wr16(REG_HCYCLE, 928);
wr16(REG_HOFFSET, 88);
wr16(REG_HSYNC0, 0);
wr16(REG_HSYNC1, 48);
wr16(REG_VCYCLE, 525);
wr16(REG_VOFFSET, 32);
wr16(REG_VSYNC0, 0);
wr16(REG_VSYNC1, 3);
wr8(REG_SWIZZLE, 0);
wr8(REG_PCLK_POL, 1);
wr8(REG_CSPREAD, 0);
wr16(REG_HSIZE, 480);
wr16(REG_VSIZE, 800);

//CMD_DLSTART;      //Set display list address to 0
   
    wr32(RAM_DL + 0, CLEAR_COLOR_RGB(0,0,0)); //CLEAR_COLOR_RGB0,0,0
    wr32(RAM_DL + 4, CLEAR(1,1,1));
    wr32(RAM_DL + 8, DISPLAY); //DISPLAY

    wr8(REG_DLSWAP,0x02);         //Send 0x02 because the programming guide says 10 (0x02) is recommended in most cases. Go to REG_DLSWAP for more info.
    wr8(REG_GPIO_DIR,0x80);
    wr8(REG_GPIO,0x80);
    wr8(REG_PCLK,5);
   
}
*/

bool InitializeTrigger = true;               //To trigger initialization once in the beginning

void loop() {
  // put your main code here, to run repeatedly:


  /*
if( InitializeTrigger == true){

initialize();

InitializeTrigger = false;
}
*/

   // CMD_DLSTART;      //Set display list address to 0
   
   // wr32(RAM_DL + 0, CLEAR_COLOR_RGB(0,0,255)); //CLEAR_COLOR_RGB0,0,0
    //wr32(RAM_DL + 4, CLEAR(1,1,1));
    //wr32(RAM_DL + 8, 0x00);
 
}

Attached is the header file and logic waveform.
« Last Edit: May 12, 2020, 07:01:27 AM by SpicyChef »
Logged

FTDI Community

  • Administrator
  • Sr. Member
  • *****
  • Posts: 443
    • View Profile
Re: FT813 initialization
« Reply #3 on: May 12, 2020, 11:16:16 AM »

Hi,

Yes, it looks like your MISO line is always being read as high, it would be worth checking the pin settings on the Arduino to ensure this line can read correctly. You could disconnect from EVE and pull low and see if it clocks in 0's. It could also be the chip select line etc. which may have bad connection to EVE and so EVE never gets selected.

Note that rd8 is only needing 3 bytes address, 1 dummy and then 1 dummy byte for the data. I suspect you added more as a debug measure to see if the 7C came back but just to mention anyway. BRT_AN_006 has examples of the write and read data bit formats.

Best Regards, FTDI Community
Logged

SpicyChef

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: FT813 initialization
« Reply #4 on: May 17, 2020, 10:36:51 PM »

Hello,

So I got the FT813 to communicate back correctly. I'm still having trouble making the display show what I want, in this case a blue screen. I followed the code you recommended but no luck.

In the zip file attached is my code and logic analyzer file along with a screenshot showing the correct communication.

Here is the code

#include <SPI.h>
#include "functions.h"





void setup() {
  // put your setup code here, to run once:
pinMode(ChipSelectPin, OUTPUT);
pinMode(INT_N, OUTPUT);
pinMode(PD_N, OUTPUT);
digitalWrite(ChipSelectPin, HIGH);   //When ChipSelectPin is high you can't communicate with FT81X
digitalWrite(INT_N, HIGH);           //deactivate interrupt to host
digitalWrite(PD_N, HIGH);            //deactivate Chip power down mode




Serial.begin(9600);

//initialise SPI
SPI.begin();
SPI.setBitOrder(MSBFIRST);          //Not strictly needed but just to be sure
SPI.setDataMode(SPI_MODE0);         //Not stirctly needed but just to be sure
}


void initialize(){

digitalWrite(PD_N, LOW);           //PD low to reset the device
delay(20);
digitalWrite(PD_N, HIGH);          //PD high again
delay(20);

host_command(ACTIVE);              //Send ACTIVE (0x00) to wake the FT81X
delay(300);

rd8(REG_ID);                        //Read the chip's ID 
rd8(REG_CPURESET);                  //Ensure CPURESET register reads 0 and FT81X is ready $$

wr16(REG_HCYCLE, 928);
wr16(REG_HOFFSET, 88);
wr16(REG_HSYNC0, 0);
wr16(REG_HSYNC1, 48);
wr16(REG_VCYCLE, 525);
wr16(REG_VOFFSET, 32);
wr16(REG_VSYNC0, 0);
wr16(REG_VSYNC1, 3);
wr8(REG_SWIZZLE, 0);
wr8(REG_PCLK_POL, 1);
//wr8(REG_CSPREAD, 0);
wr16(REG_HSIZE, 800);
wr16(REG_VSIZE, 480);

byte FT81X_GPIO;
FT81X_GPIO=rd8(REG_GPIO);
bitSet(FT81X_GPIO,7);
wr8(REG_GPIO, FT81X_GPIO);     

    wr32(RAM_DL + 0, CLEAR_COLOR_RGB(0,0,0)); //CLEAR_COLOR_RGB0,0,0
    wr32(RAM_DL + 4, CLEAR(1,1,1));
    wr32(RAM_DL + 8, DISPLAY); //DISPLAY

    wr8(REG_DLSWAP,0x02);         //Send 0x02 because the programming guide says 10 (0x02) is recommended in most cases. Go to REG_DLSWAP for more info.
    wr8(REG_PCLK,2);
    wr8(REG_PWM_DUTY, 127);

}

bool InitializeTrigger = true;               //To trigger initialization once in the beginning

void loop() {
  // put your main code here, to run repeatedly: 
if( InitializeTrigger == true){
initialize();
InitializeTrigger = false;
}
    wr32(RAM_DL + 0, CLEAR_COLOR_RGB(0,0,255)); //CLEAR_COLOR_RGB0,0,0
    wr32(RAM_DL + 4, CLEAR(1,1,1));
    wr32(RAM_DL + 8, DISPLAY);

}
Logged

FTDI Community

  • Administrator
  • Sr. Member
  • *****
  • Posts: 443
    • View Profile
Re: FT813 initialization
« Reply #5 on: May 18, 2020, 03:02:07 PM »

Hello,

Each time you want to update the screen, you must also have a swap as the display list has two buffers. After writing the new list, you swap that one so that it becomes active and you can edit the other one and so on. Therefore, try adding a swap after your DISPLAY in your main loop at the bottom.


    wr32(RAM_DL + 0, CLEAR_COLOR_RGB(0,0,255)); //CLEAR_COLOR_RGB0,0,0
    wr32(RAM_DL + 4, CLEAR(1,1,1));
    wr32(RAM_DL + 8, DISPLAY);
    wr8(REG_DLSWAP,0x02); 


Best Regards, FTDI Community
Logged

SpicyChef

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: FT813 initialization
« Reply #6 on: May 18, 2020, 04:20:23 PM »

Unfortunately still doesn't work, all I can see is the back light turning on.
I'm not sure where I'm going wrong with the code, since the logic reading seems to be good.

If you could look at the logic reading and help me, it would be greatly appreciated.
Logged

Rudolph

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: FT813 initialization
« Reply #7 on: May 19, 2020, 07:15:07 AM »

I have an Arduino example for my driver library: https://github.com/RudolphRiedel/FT800-FT813/tree/4.x/example_projects

The display is selected in EVE_config.h.
And the pins for CS and PD are configured at the end of EVE_target.h.
Logged

SpicyChef

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: FT813 initialization
« Reply #8 on: May 22, 2020, 02:47:36 PM »

Rudolph,

Thanks to your code I was able to find the problem in mine.
Logged