NHD-2.7-12864UCY3 yellow columns occur under ascii characters

Comments

6 comments

  • Paul_B

    Hello,

    Thank you for reaching out. It would appear that there is a slight issue with your initialization sequence / timing. I recommend double checking your code with what is listed on page 11 in the displays datasheet.

    https://newhavendisplay.com/content/specs/NHD-2.7-12864UCY3.pdf 

    Please feel free to share you code, hope this helps!

    0
  • bsoyer

    Hello Paul,
    Thanks for the quick reply.I double check my initialization sequence and SPI timing, I noticed that SPI timing is alittle bit faster than controller's expected freq. I fixed it and in order to simplify my code I decide to draw a rectangle but again I get the same result (dark-yellow columns occur above and below). I am using PIC32MX795F512L and my code is below

    /* Adds support for PIC32 Peripheral library functions and macros */
    #include "plib.h"
    #include "proc/p32mx795f512l.h"

    extern char ASCII[][5];
    extern char logo[][32];

    // Configuration Bits
    #pragma config FNOSC    = PRIPLL        // Oscillator Selection
    #pragma config FPLLIDIV = DIV_5         // PLL Input Divider (PIC32 Starter Kit: use divide by 2 only)
    #pragma config FPLLMUL  = MUL_16        // PLL Multiplier
    #pragma config FPLLODIV = DIV_1         // PLL Output Divider
    #pragma config FPBDIV   = DIV_1         // Peripheral Clock divisor
    #pragma config FWDTEN   = OFF           // Watchdog Timer
    #pragma config WDTPS    = PS1           // Watchdog Timer Postscale
    #pragma config FCKSM    = CSDCMD        // Clock Switching & Fail Safe Clock Monitor
    #pragma config OSCIOFNC = OFF           // CLKO Enable
    #pragma config POSCMOD  = XT            // Primary Oscillator
    #pragma config IESO     = OFF           // Internal/External Switch-over
    #pragma config FSOSCEN  = OFF           // Secondary Oscillator Enable
    #pragma config CP       = OFF           // Code Protect
    #pragma config BWP      = OFF           // Boot Flash Write Protect
    #pragma config PWP      = OFF           // Program Flash Write Protect
    #pragma config ICESEL   = ICS_PGx1      // ICE/ICD Comm Channel Select
    #pragma config DEBUG    = ON           // Debugger Disabled for Starter Kit

    // application defines
    #define SYS_FREQ      (80000000)

    // prototype
    void DelayMs(unsigned int);
    void DelayUs(unsigned int);
    void SPI_1();
    void LCD_Initialization();
    void LCD_Function();
    void lcd_create_rect(int st_row,int st_col,int end_row,int end_col, int color);
    void lcd_set_col_addr(int start, int end);
    void lcd_set_row_addr(int start, int end);
    void LCD_clear();

    char spi_data[1048];
    char last_row = 56;
    char last_col = 0;
    //  blink_leds application code
    int main(void)
    {
          SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);
       LCD_Function();
       return 0;
    }

    /******************************************************************************
    *   DelayMs()
    *
    *   This functions provides a software millisecond delay
    ******************************************************************************/
    void DelayMs(unsigned int msec)
    {
       unsigned int tWait, tStart;
          
        tWait=(SYS_FREQ/2000)*msec;
        tStart=ReadCoreTimer();
        while((ReadCoreTimer()-tStart)<tWait);      // wait for the time to pass
       return;
    }
    void DelayUs(unsigned int usec)
    {
       unsigned int tWait, tStart;
          
        tWait=(SYS_FREQ/2000000)*usec;
        tStart=ReadCoreTimer();
        while((ReadCoreTimer()-tStart)<tWait);      // wait for the time to pass
       return;
    }
    /******************************************************************************/
    void SPI_1()
    {

       int rData;
       IEC0CLR=0x03800000; // disable all interrupts
       SPI1CON = 0; // Stops and resets the SPI1.
       rData=SPI1BUF; // clears the receive buffer
       IFS0CLR=0x03800000; // clear any existing event
       IPC5CLR=0x1f000000; // clear the priority
       IPC5SET=0x0d000000; // Set IPL=3, Subpriority 1
       IEC0SET=0x03800000; // Enable RX, TX and Error interrupts
       SPI1BRG=19; // FPB/2(baud+1) => 80Mhz / 2*20 = 2 Mhz clock frequency
       SPI1STATCLR=0x40; // clear the Overflow
       SPI1CON=0x8260; // SPI ON, 8 bits transfer, SMP=1, Master mode
    }
    /******************************************************************************/
    void SPI_Write(int byte_count, char* data, int dataOrComm)
    {
       int count;
       // give data or command
       LATCbits.LATC2=dataOrComm;
       // assert CS
       LATDbits.LATD9=0;
       // wait till spi is busy
       for (count=0;count<byte_count;count++)
       {
          SPI1BUF=data[count];
          while (SPI1STATbits.SPIBUSY==1);
       }
       // deassert CS
       LATDbits.LATD9=1;
       DelayMs(1);
    }

    void LCD_Initialization()
    {   
       int i,j;   
          
       //Set display off
       spi_data[0]=0xAE;
       SPI_Write(1,&spi_data[0],0);

       //Set Display Clock
       spi_data[0]=0xB3;
       spi_data[1]=0x91;
       SPI_Write(2,&spi_data[0],0);

       //Set Multiplex Ratio
       spi_data[0]=0xA8;
       spi_data[1]=0x3F;
       SPI_Write(2,&spi_data[0],0);
       
       //Set Display Offset
       spi_data[0]=0xA2;
       spi_data[1]=0x4C;//0x44;
       SPI_Write(2,&spi_data[0],0);

       // Set Start Line
       spi_data[0]=0xA1;
       spi_data[1]=0x00;
       SPI_Write(2,&spi_data[0],0);

       // Set Master Config
       spi_data[0]=0xAD;
       spi_data[1]=0x00;
       SPI_Write(2,&spi_data[0],0);

       // Set ReMap
       spi_data[0]=0xA0;
       spi_data[1]=0x50;//0x44;
       SPI_Write(2,&spi_data[0],0);

       // Set Current Range
       spi_data[0]=0x86;   
       SPI_Write(1,&spi_data[0],0);

       // Set Gray Scale
       spi_data[0]=0xB8;
       spi_data[1]=0x01;
       spi_data[2]=0x11;
       spi_data[3]=0x22;
       spi_data[4]=0x32;
       spi_data[5]=0x43;
       spi_data[6]=0x54;
       spi_data[7]=0x65;
       spi_data[8]=0x76;
       SPI_Write(9,&spi_data[0],0);

       // Set Contrast
       spi_data[0]=0x81;
       spi_data[1]=0x7F;
       SPI_Write(2,&spi_data[0],0);

       //Set Frame Frequency
       spi_data[0]=0xB2;
       spi_data[1]=0x51;
       SPI_Write(2,&spi_data[0],0);   

       //Set Phase Length
       spi_data[0]=0xB1;
       spi_data[1]=0x55;
       SPI_Write(2,&spi_data[0],0);

       // Set Precharge Voltage
       spi_data[0]=0xBC;
       spi_data[1]=0x10;
       SPI_Write(2,&spi_data[0],0);

       // Set Precharge Compensation
       spi_data[0]=0xB4;
       spi_data[1]=0x02;
       SPI_Write(2,&spi_data[0],0);

       //Enable Pre-Charge Compensation
       spi_data[0]=0xB0;
       spi_data[1]=0x28;
       SPI_Write(2,&spi_data[0],0);

       // Set High Voltage Level of COM Pin
       spi_data[0]=0xBE;
       spi_data[1]=0x1C;
       SPI_Write(2,&spi_data[0],0);

       // Set Low Voltage Level of SEG Pin
       spi_data[0]=0xBF;
       spi_data[1]=0x0D;
       SPI_Write(2,&spi_data[0],0);   
       
       // Set Display Mode
       spi_data[0]=0xA4;
       SPI_Write(1, &spi_data[0],0);

       // Clear Screen
       LCD_clear();
       // Set Display on
       spi_data[0]=0xAF;
       SPI_Write(1,&spi_data[0],0);
    }
    void LCD_clear()
    {
       char i,j;
       lcd_set_row_addr(0,63);
       lcd_set_col_addr(0,127);
       for (i=0;i<64;i++)
       {
          for ( j=0;j<64;j++)
          {
          spi_data[0]=0x00;
          SPI_Write(1,&spi_data[0],1);
          }
       }
       return;   
    }
    void LCD_Function()
    {
       char spi_data[1048];
       char start_row = 0x00;
       char start_col = 0x00;
        char character = 0x20;
       // RESET
       TRISCbits.TRISC3=0;
       LATCbits.LATC3=0;
       DelayMs(50);
       LATCbits.LATC3=1;
       // Set D/C bit as output
       TRISCbits.TRISC2=0;
       //Set CS bit as output
       TRISDbits.TRISD9=0;
       LATDbits.LATD9=1;   
       
       SPI_1();
       LCD_Initialization();
       
    //   Enable Rectangle engine
       spi_data[0]=0x23;
       spi_data[1]=0x03;
       SPI_Write(2,&spi_data[0],0);

       lcd_create_rect(10,10,24,30,0xFF);
    }

    void lcd_create_rect(int st_row,int st_col,int end_row,int end_col, int color)
    {
       spi_data[0]=0x24;
       spi_data[1]=st_col;
       spi_data[2]=st_row;
       spi_data[3]=end_col;
       spi_data[4]=end_row;
       spi_data[5]=color;
       SPI_Write(6,&spi_data[0],0);
    }

    void lcd_set_col_addr(int start, int end)
    {
       spi_data[0]=0x15;
       spi_data[1]=start;
       spi_data[2]=end;
       SPI_Write(3,&spi_data[0],0);
    }
    void lcd_set_row_addr(int start, int end)
    {
       spi_data[0]=0x75;
       spi_data[1]=start;
       spi_data[2]=end;
       SPI_Write(3,&spi_data[0],0);
    }
    0
  • bsoyer

    solved!!! After trying lots of combinations, I decided to comment out the initialization code step by step, I noticed that when I removed the master config part (below) from the init code the problem is solved.

    // Set Master Config
       spi_data[0]=0xAD;
       spi_data[1]=0x00;
       SPI_Write(2,&spi_data[0],0);

    0
  • Paul_B

    Fantastic, enjoy your display! :)

    0
  • tracyb

    I have the same config settings as you. Commenting out the master config settings does nothing. SLowing down the Serial comms does nothing too. My voltages are stable. Any ideas? Config shown below:

    //begin the initialisation of the screen

       //turn the screen off 0xAF
       write_to_address(0xAE);

       delay(100);

       //set clock to 135 frames per second
       write_to_address(0xB3); //clock
       write_to_address(0x91); //clock

       //set multiplex ratio (0x3F)
       write_to_address(0xA8); //clock
       write_to_address(0x3F); //clock

       //display offset(0x4c)
       write_to_address(0xA2);
       write_to_address(0x4C);

       //set start line (0x00)
       write_to_address(0xA1); //set start line
       write_to_address(0x00); //to 00

       //set master config
       write_to_address(0xAD);
       write_to_address(0x00);

       //remap format (0x50)
       write_to_address(0xA0);
       write_to_address(0x50);

       //set current range to full range
       write_to_address(0x86);

       //set greyscale
       write_to_address(0xB8);
       write_to_address(0x01);
       write_to_address(0x11);
       write_to_address(0x22);
       write_to_address(0x32);
       write_to_address(0x43);
       write_to_address(0x54);
       write_to_address(0x65);
       write_to_address(0x76);

       //set contrast
       write_to_address(0x81);
       write_to_address(0x7F);

       //set frame frequency
       write_to_address(0xB2);
       write_to_address(0x51);

       //set phase length
       write_to_address(0xB1);
       write_to_address(0x55);

       //set precharge voltage
       write_to_address(0xBC);
       write_to_address(0x10);

       //set precharge compensation
       write_to_address(0xB0);
       write_to_address(0x28);

       //set high voltage level of com pin
       write_to_address(0xBE);
       write_to_address(0x1C);

       //set low voltage level of seg pin
       write_to_address(0xBF);
       write_to_address(0x0D);

       //set display mode
       write_to_address(0xA4);

       write_to_address(0xA1); //set start line
       write_to_address(0x00); //to 00


       write_to_address(0x75);
       write_to_address(0x00);
       write_to_address(0x3F);

       write_to_address(0x15); //columns
       write_to_address(0x00);
       write_to_address(0x3f);

       uint8_t i,j;

       for(i=0;i<32;i++){ //16 rows
          for(j=0;j<64;j++)
          {
             write_to_address(0x00);
          }

       }

       //turn the screen on 0xAF
       write_to_address(0xAF);
       //delay(5000000);
    0
  • tracyb

    Nevermind -  I solved it.

    In the Newhaven code the send in 0x00 so I thought that we needed to disable both the DC to DC converter and the VCOMH. But if you go into their code the command actually ORs this with 0x02.

    Changed that and the ghosting is all gone.

    0

Please sign in to leave a comment.