Arduino MEGA 2560 + NHD240128

Comments

6 comments

  • papalyle

    Hello,

    You have quite a bit of code there. Did you test it a little bit at a time or just type it all in at once? How much $$$ do you have invested in your project, I wonde if I could raise that much. I have an application kind of like but not a road map. Maybe we could hehp each other at some time in the not too distant future. I have several years of successful software, but it's not current What language are you programming in?

    papalyle

    0
  • tvieil

    i type it in one time, but i worked  on several versions, it seems that delay() function is not respected for 1ms and around this value. I'm looking for safe instructions for small delay to respect timing diagram. I do not know if my LCD is not dead , i bought it 2 years ago just now that i try it, it sweeps matrix, contrast is enable. I used sample of New Heaven in datasheet. I hope that  we can help each other. I do not find functionnal codes on the web for Arduino Uno or other.

    i found this link http://en.radzio.dxp.pl/t6963/ but don't have enough expériences to compile with avr-gcc and  transfert code   without Arduino IDE (i worked on several langages)

    0
  • Michael_L
    Are you seeing anything on the display?  Do you have any others to test?  Also, can you please provide the full part number of the display?
    0
  • tvieil

    Here is a link to serial of the LCD & Strange Things displayed
    https://plus.google.com/photos/107056513026123850606/albums/6008524498068070529


    I found a way to use Atmel Studio 6.2 without transfer interface with my Arduino MEGA2560,
    then I tested the code of another person lol

    https://plus.google.com/107056513026123850606/posts/ZKgBnyQsq9t

    Thank you Radosław Kwiecień
    (http://en.radzio.dxp.pl/t6963/)

    A demo that i've made http://youtu.be/c0WBgH5u-VI

    0
  • tvieil

    Here is my functional code reviewed and corrected for the Arduino IDE interface

    // T.VIEIL - Tuesday 6th May 2014
    // Sample code to use NHD240128 with an Arduino MEGA 2560


    // PORTA is used for LCD lines DB0 to DB7
    // PA0(22)  to PA7(29) on Arduino MEGA 2560


    // control signals
    #define GLCD_WR PC0 // PORTC. PC0 (37) Active LOW Write signal
    #define GLCD_RD PC1 // PORTC. PC1 (36)  Active LOW Read signal
    #define GLCD_CE PC2 // PORTC. PC2 (35) Active LOW Chip Select signal
    #define GLCD_CD PC3 // PORTC. PC3 (34)  Register select signal.  C/D=1: Command  C/D=0: Data
    #define GLCD_RESET         PC4 // PORTC. PC4 (33) Active LOW Reset signal
    #define GLCD_FS PC5 // PORTC. PC5 (32) Font select signal. H: 6x8,  L: 8x8   

    // MD2  pin of LCD go to Vss (GND)


    void setup() {


    DDRA = 0xFF;
    DDRC = ((1 << GLCD_WR) | (1 << GLCD_RD) | (1 << GLCD_CE) | (1 << GLCD_CD) | (1 << GLCD_RESET) | (1 << GLCD_FS));
    PORTC |= ((1 << GLCD_WR) | (1 << GLCD_RD) | (1 << GLCD_CE) | (1 << GLCD_CD) | (1 << GLCD_RESET) | (1 << GLCD_FS));


    // reset /RESET
    PORTC &= ~(1 << GLCD_RESET);
    delayMicroseconds(1000);

    // set /RESET
    PORTC |= (1 << GLCD_RESET);
    PORTC &=  ~(1 << GLCD_FS);
    delayMicroseconds(1000);

    InitLCD();
     
    }


    void Writecom(int Command){
     
    while (!StatusLCDCheck()) {}

    PORTA = Command;                 //move data to portA

    PORTC  &= ~((1 << GLCD_WR) | (1 << GLCD_CE));
    delayMicroseconds(1);       
    PORTC |= ((1 << GLCD_WR) | (1 << GLCD_CE));


    }

    void Writedata(int data){
     
    while (!StatusLCDCheck()) {}
     
    DDRA |= 0b11111111;  //pins 0 to 7 as outputs
    PORTA = data;        //move data to portA

    PORTC &= ~((1 << GLCD_WR) | (1 << GLCD_CE) | (1 << GLCD_CD));                       
    delayMicroseconds(1);
    //delay1();
    PORTC |= ((1 << GLCD_WR) | (1 << GLCD_CE) | (1 << GLCD_CD));

    }

    boolean StatusLCDCheck() {
    // Status Check
    // The Status of RA6963 can be read from the data lines.
    // RD  WR  CS  C/D  SD[7:0]
    // L    H   L   H  Status Word

    int LCD_STATUS;
    DDRA = 0x00;  //pins 0 to 7 as inputs

    PORTC &=  0b11111001; //RESET /CS et /RD
    delayMicroseconds(1);
    //delay1();
    LCD_STATUS = PINA; //READ PORTA
    PORTC |= 0b00000110;  // set /CS et /RD

    DDRA = 0xFF;  //pins 0 to 7 as outputs
     
    if (LCD_STATUS && B00000011) {

        return true;
      }
      else
    {return false;}

    }



    void InitLCD(){

    Writedata(0xE0);
    Writedata(0x01);   //graphic home address =01E0h
    Writecom(0x42);    //graphic home address set

    Writedata(0x1E);
    Writedata(0x00);   //graphic area = 001Eh
    Writecom(0x43);    //graphic area control set 

    Writedata(0x00);
    Writedata(0x00);   //text address = 0000h
    Writecom(0x40);    //text home address set

    Writedata(0x1E);
    Writedata(0x00);   //text area address = 001Eh
    Writecom(0x41);    //text area control set 

    Writedata(0x02);
    Writedata(0x00);   
    Writecom(0x22);    //set offset register

    Writecom(0x9C);    //set display mode = text ON + graphic ON

    Writecom(0x80);    //set display mode = Internal CGROM + OR

    //-------------------------------------------------------------------------------------------------
    //
    // Clears text area of display RAM memory
    //
    //-------------------------------------------------------------------------------------------------

    int i;


    Writedata(0x0000 & 0xFF);   //TEXT HOME
    Writedata(0x0000 >> 8);
    Writecom(0x24);    //SET ADDRESS POINTER

    for(i = 0; i < 900; i++) //TEXT SIZE
      {
    Writedata(0x00);
    Writecom(0xC0);   //DATA WRITE_AND_INCREMENT
      }


    //-------------------------------------------------------------------------------------------------
    //
    // Clears graphics area of display RAM memory
    //
    //-------------------------------------------------------------------------------------------------

    Writedata(0x01E0 & 0xFF);   //GRAPHIC HOME
    Writedata(0x01E0 >> 8);
    Writecom(0x24);             //SET ADDRESS POINTER

    for(i = 0; i < 3840; i++)   //GRAPHIC SIZE
      {

    Writedata(0x00);
    Writecom(0xC0);   //DATA WRITE_AND_INCREMENT        
      }



    }


    void loop()
    {
     
    int i;

    Writedata(0x0000 & 0xFF);   //TEXT HOME
    Writedata(0x0000 >> 8);
    Writecom(0x24);    //SET ADDRESS POINTER

    boolean Halt = false;

    while(Halt == false) {


    //***********************************************
    //***    it will display the characters of CGROM              ***
    //***********************************************
    //e.g 0x21 Letter A

    for (i = 0; i<128;i++) {
      Writedata(i);                     // Write a character
      Writecom(0xC0);              //Data Write and Increment ADP
     }
     
    Halt = true;
    }

    }
    0
  • Michael_L

    Thank you for sharing!

    0

Please sign in to leave a comment.