# define LCD_DELAY 400 # define LCD_PORT P0 # define RS P0_0 # define RW P0_2 # define EN P0_1 bit gbStatus = 0; /* *************************************************************************************** */ void Delay(unsigned int j) { unsigned int i; for(i = 0; i < j ; i++); } /* *************************************************************************************** */ void LcdInitWrite(unsigned char ucCmd) { RW = 0; LCD_PORT = ucCmd; EN = 1; Delay(LCD_DELAY); EN = 0; } /* *************************************************************************************** */ void LcdCmd(unsigned char ucCmd) { unsigned char ucTemp; if(gbStatus) { gbStatus=0; goto NEXT; } NEXT: RW = 0; ucTemp = ucCmd; ucTemp &= 0xf0; LCD_PORT &= 0x0f; LCD_PORT |= ucTemp; ucTemp = (ucCmd << 4); ucTemp &= 0xf0; LCD_PORT &= 0x0f; LCD_PORT |= ucTemp; EN = 1; Delay(LCD_DELAY); EN = 0; } /* *************************************************************************************** */ void LcdData(unsigned char ucData) { gbStatus = 1; RS = 1; LcdCmd(ucData); } /* *************************************************************************************** */ void LcdInit(void) { LcdCmd(0x28); Delay(LCD_DELAY); LcdCmd(4); Delay(LCD_DELAY); LcdCmd(0x85); Delay(LCD_DELAY); LcdCmd(6); Delay(LCD_DELAY); LcdCmd(1); Delay(LCD_DELAY); } /* *************************************************************************************** */ void LcdPuts(unsigned char *ucStr) { unsigned int i; for(i = 0; ucStr[i] !=0 ; i++) LcdData(ucStr[i]); } /* *************************************************************************************** */ void LcdPutc(unsigned char ucCh) { LcdData(ucCh); }
When i am trying to build the hex. i am getting the following errors help.very urgent. Build target 'Target 1' compiling lcd.c... LCD.C(21): error C202: 'P0_2': undefined identifier LCD.C(22): error C202: 'P0': undefined identifier LCD.C(23): error C202: 'P0_1': undefined identifier LCD.C(25): error C202: 'P0_1': undefined identifier LCD.C(40): error C202: 'P0_2': undefined identifier LCD.C(43): error C202: 'P0': undefined identifier LCD.C(44): error C202: 'P0': undefined identifier LCD.C(47): error C202: 'P0': undefined identifier LCD.C(48): error C202: 'P0': undefined identifier LCD.C(49): error C202: 'P0_1': undefined identifier LCD.C(51): error C202: 'P0_1': undefined identifier LCD.C(58): error C202: 'P0_0': undefined identifier Target not created
And since you are a very bright person, you instantly jumped to the compiler manual, and checked how Keil describes that you should declare bit variables for accessing individual processor pins.
What did the manual tell you?