This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

P89V664 Serial Graphical LCD Problem

Hello

I have confused in the coding of the Serial Graphical LCD on NXP P89V664.

Can any one help ????

the code is

#include<reg52.H>
#include<stdio.h>
#include<intrins.h>

// #define unsigned char unsigned char // 0~255
// #define unsigned int unsigned int   // 0~65535

sbit _CS = P2^3;
sbit _RST = P2^2;
sbit A0 = P2^1;
sbit SCK = P4^0;
sbit DIN = P4^2;

unsigned char ContrastLevel;     // for contrast setting level

//-----------------------------------
// dispaly data (128x64)
//-----------------------------------

unsigned char code Logo[]={

....0x15,0x06,0x00,0x00,0x10,0x1F,0x10,0x00,0x00,0x12,0x15,0x15,0x15,0x88,0xC0
};

//-----------------------------------
// Delay Routine
//-----------------------------------

void delayms(unsigned int m)        // 12MHz Xtal, close to ms value
{
    unsigned int j;
    unsigned int i;

    for(i=0; i<m; i++)
        for(j=0; j<109; j++)
            _nop_();
}

//-----------------------------------
// IO Routine
//-----------------------------------

void lcd_cmd(unsigned char Command)       //send command
{
    SCK = 1;
    A0  = 0;
    _CS = 0;
    DIN = Command & 0x80; SCK= 0; SCK= 1;
    DIN = Command & 0x40; SCK= 0; SCK= 1;
    DIN = Command & 0x20; SCK= 0; SCK= 1;
    DIN = Command & 0x10; SCK= 0; SCK= 1;
    DIN = Command & 0x08; SCK= 0; SCK= 1;
    DIN = Command & 0x04; SCK= 0; SCK= 1;
    DIN = Command & 0x02; SCK= 0; SCK= 1;
    DIN = Command & 0x01; SCK= 0; SCK= 1;
    _CS = 1;
}

void lcd_data(unsigned char DData)        //send data
{
    SCK= 1;
    A0  = 1;
    _CS = 0;
    DIN = DData & 0x80; SCK= 0; SCK= 1;
    DIN = DData & 0x40; SCK= 0; SCK= 1;
    DIN = DData & 0x20; SCK= 0; SCK= 1;
    DIN = DData & 0x10; SCK= 0; SCK= 1;
    DIN = DData & 0x08; SCK= 0; SCK= 1;
    DIN = DData & 0x04; SCK= 0; SCK= 1;
    DIN = DData & 0x02; SCK= 0; SCK= 1;
    DIN = DData & 0x01; SCK= 0; SCK= 1;
    _CS = 1;
}

//-----------------------------------
// Write a Screen
//-----------------------------------
void WriteScreen(unsigned char *DisplayData)    // DisplayData should be 164x64/8 = 1312byte
{
    unsigned char TempData;
    unsigned char i, j;
    for(i=0;i<8;i++)
        {
        lcd_cmd(0xb0 | i);    // select page 0~7
        lcd_cmd(0x10);        // start form column 4
        lcd_cmd(0x00);        // (2byte command)
        for(j=0;j<128;j++)
                {
            TempData=(*(DisplayData+(i*128)+j));
            lcd_data(TempData);
            }
        }
}

//-----------------------------------
// Contrast control
//-----------------------------------
void LCD_Darker(void)
{
    if (ContrastLevel<0x3F)
        {
        ContrastLevel++;
        }
    lcd_cmd(0x81);            // E-Vol setting
    lcd_cmd(ContrastLevel);   // (2byte command)
}



void LCD_Lighter(void)
{
    if (ContrastLevel>0x00)
        {
         ContrastLevel--;
        }
    lcd_cmd(0x81);            // E-Vol setting
    lcd_cmd(ContrastLevel);   // (2byte command)
}


//-----------------------------------
// Init LCD module
//-----------------------------------
void initLCDM(void)
{
    _RST=1;                 // hardware reset LCD module
    _RST=0;
    delayms(1);
    _RST=1;
    delayms(800);

    ContrastLevel=0x17;     // default Contrast Level  1a
    lcd_cmd(0xab);                      //new
    lcd_cmd(0xaf);            // display on
    lcd_cmd(0x40);            // display start line=0
    lcd_cmd(0xc8);            // Common output mode select= reverse
    lcd_cmd(0xa6);            // normal display
    lcd_cmd(0xa4);            // Duisplay all point = off
    lcd_cmd(0xa3);            // LCD bias = 1/9   a2
    lcd_cmd(0x2f);            // Power control = all on
    lcd_cmd(0x25);            // Rab Ratio     26
    lcd_cmd(0x81);            // E-Vol setting
    lcd_cmd(ContrastLevel);   // (2byte command)
}

//-----------------------------------
// Main Program
//-----------------------------------
void main()
{
    SP=0x60;
    EA = 0;         // disable interrupts

    _CS    =1;
    _RST   =1;
    A0     =1;
    SCK   =1;
    DIN    =1;

    initLCDM();
    WriteScreen(Logo);
    while(1)
    {
    }
}
//end of program


The error it shoes that P4 is an undefined identifier. error C202

Parents
  • This is the code for the serial graphical LCD I am using for sending the serial data to the lcd on four lines but it does not give any result at the end.

    It shows the raster image on the graphical lcd so please help for further for sending the lcd data on four lines

    #include <stdio.h>
    #include <config.h>
    #include <lcd128x64.h>                                    // definitions for the LCD controller
    #include <fonts.h>                                                // definitions for the fonts
    
    //-----------------------------------------------------------------------------
    // MAIN Routine
    //-----------------------------------------------------------------------------
    
    sbit SWT = P2^4;                                        /* eval board switch */
    
    void main (void)
    {
            config();                                                               // setup all the SFR initialization
            lcd_init();                                                             // initialize LCD display
            lcd_erase();                                                    // erase the display
    
            while(1)
            {
                    lcd_clear_area(SCRN_LEFT,SCRN_TOP,SCRN_RIGHT,SCRN_BOTTOM);
                    lcd_box(SCRN_LEFT,SCRN_TOP,SCRN_RIGHT,SCRN_BOTTOM);
                    lcd_box(SCRN_LEFT+2,SCRN_TOP+2,SCRN_RIGHT-2,SCRN_BOTTOM-2);
                    lcd_text(4,4,FONT_NINE_DOT," Priyank Rathod");
                    lcd_text(6,29,FONT_NINE_DOT,"128x64");
                    lcd_text(60,32,FONT_SEVEN_DOT," Toggling");
                    lcd_text(17,52,FONT_SIX_DOT,"">http://www.google.com");
                    lcd_update(SCRN_TOP,SCRN_BOTTOM);
    
                    while(SWT == 1);
                    while(SWT == 0);
    
                    lcd_invert_area(SCRN_LEFT+3,SCRN_TOP+3,SCRN_RIGHT-3,SCRN_BOTTOM-3);
                    lcd_update(SCRN_TOP,SCRN_BOTTOM);
    
                    while(SWT == 1);
                    while(SWT == 0);
    
            }
    }
    

Reply
  • This is the code for the serial graphical LCD I am using for sending the serial data to the lcd on four lines but it does not give any result at the end.

    It shows the raster image on the graphical lcd so please help for further for sending the lcd data on four lines

    #include <stdio.h>
    #include <config.h>
    #include <lcd128x64.h>                                    // definitions for the LCD controller
    #include <fonts.h>                                                // definitions for the fonts
    
    //-----------------------------------------------------------------------------
    // MAIN Routine
    //-----------------------------------------------------------------------------
    
    sbit SWT = P2^4;                                        /* eval board switch */
    
    void main (void)
    {
            config();                                                               // setup all the SFR initialization
            lcd_init();                                                             // initialize LCD display
            lcd_erase();                                                    // erase the display
    
            while(1)
            {
                    lcd_clear_area(SCRN_LEFT,SCRN_TOP,SCRN_RIGHT,SCRN_BOTTOM);
                    lcd_box(SCRN_LEFT,SCRN_TOP,SCRN_RIGHT,SCRN_BOTTOM);
                    lcd_box(SCRN_LEFT+2,SCRN_TOP+2,SCRN_RIGHT-2,SCRN_BOTTOM-2);
                    lcd_text(4,4,FONT_NINE_DOT," Priyank Rathod");
                    lcd_text(6,29,FONT_NINE_DOT,"128x64");
                    lcd_text(60,32,FONT_SEVEN_DOT," Toggling");
                    lcd_text(17,52,FONT_SIX_DOT,"">http://www.google.com");
                    lcd_update(SCRN_TOP,SCRN_BOTTOM);
    
                    while(SWT == 1);
                    while(SWT == 0);
    
                    lcd_invert_area(SCRN_LEFT+3,SCRN_TOP+3,SCRN_RIGHT-3,SCRN_BOTTOM-3);
                    lcd_update(SCRN_TOP,SCRN_BOTTOM);
    
                    while(SWT == 1);
                    while(SWT == 0);
    
            }
    }
    

Children
No data