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
Note that sbit is a proprietary extension to the 'C' language, provided by Keil's C51 - it is not part of the standard language.