1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

128x64 KS0107/08 LCD

Discussion in 'Embedded' started by johnny, Oct 23, 2007.

  1. johnny

    johnny Guest

    Hi everybody,

    I am doing programming for 128x64 KS0107/08 Graphical LCD using Rabbi
    2000 microprocessor. I am new to this LCD. I couldn't find how to make
    pixel on. I tried with the program as shown below.. But I am not gettin
    display.

    On the other hand, I didn't know what will be character size, actuall
    what will be the procedure to know the size of a character..

    Kindly suggest me any idea or a sample program to display a character...




    #class auto

    /* commands for port settings */
    #define SET_RS() BitWrPortI(PDDR,&PDDRShadow,1,0) //SET RS
    #define CLR_RS() BitWrPortI(PDDR,&PDDRShadow,0,0) //CLR RS
    #define SET_EN() BitWrPortI(PDDR,&PDDRShadow,1,1) //SET EN
    #define CLR_EN() BitWrPortI(PDDR,&PDDRShadow,0,1) //CLR EN
    #define SET_CS1() BitWrPortI(PDDR,&PDDRShadow,1,2) //SET CS1
    #define CLR_CS1() BitWrPortI(PDDR,&PDDRShadow,0,2)
    //CLR CS1
    #define SET_CS2() BitWrPortI(PDDR,&PDDRShadow,1,3) //SET CS2
    #define CLR_CS2() BitWrPortI(PDDR,&PDDRShadow,0,3) //CLR CS2
    #define LCD_CS1() CLR_CS2();SET_CS1();
    #define LCD_CS2() SET_CS2();CLR_CS1();

    /* commands for LCD */
    #define DISPLAYON 0x3F /* display on */
    #define SETPAGEADR 0xB8
    /* x coordinate from 0-128 */
    #define SETBYTEADR 0x40 /* y coordinate from 0-64 */
    #define SETSTARTADR 0xC0 /* start line (z - address) */

    /* function prototypes */
    void LcdInit(void);
    void LcdWriteCmd(unsigned char );
    void LcdWriteData(unsigned char );
    void LcdDelay(void);
    void LcdClear(void);
    void LcdSetXY(int , int );

    unsigned int i,j,x,y,row,col;

    void main(void) /* Main Function */
    {
    WrPortI ( PDFR,NULL,0x00 );
    WrPortI ( PDDCR,NULL,0xFF );
    WrPortI ( PDDDR,NULL,0xFF );

    LcdInit();

    LcdClear();

    printf("\n MAIN LOOP");

    for(row = 0; row < 8 ; row++ ) {
    for(col = 0; col < 128 ; col++){
    LcdSetXY(row,col);
    LcdWriteData(0xFF);
    }
    }
    LcdClear();

    while(1);
    }

    void LcdInit(void) /* initialization of LCD */
    {
    printf("\n Init function ");

    LCD_CS1();
    LcdWriteCmd(DISPLAYON);

    LCD_CS2();
    LcdWriteCmd(DISPLAYON);
    }

    void LcdWriteCmd(unsigned char cmd) /* send command to LC
    */
    {
    printf("\n IN CMD ");
    CLR_RS();
    WrPortI(PADR,&PADRShadow,(PADRShadow | cmd));
    SET_EN();
    LcdDelay();
    CLR_EN();
    }

    void LcdWriteData(unsigned char data) /* send data to LC
    */
    {
    printf("\n In DATA ");
    SET_RS();
    WrPortI(PADR,&PADRShadow,(PADRShadow | data));
    SET_EN();
    LcdDelay();
    CLR_EN();
    }

    void LcdDelay(void) /* delay function */
    {
    for(i=0;i<10;i++){
    for(j=0;j<50;j++);
    }
    }

    void LcdClear(void) /* clear screen LCD */
    {
    for(x=0; x<8; x++){
    for(y = 0; y < 128; y++){
    LcdSetXY(x,y);
    LcdWriteData(0x00);
    }
    }
    }

    void LcdSetXY(int x, int y) /* set pixel at a given pos
    */
    {
    if( y < 64 ){
    LCD_CS1();
    if(x < 8)
    LcdWriteCmd(SETPAGEADR | x);
    LcdWriteCmd(SETBYTEADR | y);
    }
    else {
    LCD_CS2();
    if(x < 8)
    LcdWriteCmd(SETPAGEADR | x);
    LcdWriteCmd(SETBYTEADR | y);
    }
    }
     
    johnny, Oct 23, 2007
    #1
    1. Advertisements

  2. johnny

    jetmarc Guest

    Hi Johnny,

    Without having looked at your source code: standard troubleshooting
    for a blank LCD screen is to check the contrast voltage. Always
    worked for me.

    Regards,
    Marc
     
    jetmarc, Oct 23, 2007
    #2
    1. Advertisements

  3. johnny

    aheadcon Guest

    Hi Jonny,

    I have used a www.ramtex.dk driver. It sets a number of registers
    in the initialization sequence. Manu controllers require a number
    of settings. I'm not sure that your LcdInit is complete:
    Try to read your display controller manual for hints.
     
    aheadcon, Oct 24, 2007
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.