Hello!!!!!!!!! I have posted my program and the building message and errors below.Please solve the following errors and warning.
#include <lpc21xx.h> #define RS 1<<4 // for write operation R/W pin of lcd is zero , so it is always grounded and not necessary to define // #define EN 1<<5 void delay(void) { unsigned int d; for(d=0; d<1000000; d++) { } } void outdata(unsigned char x) // send the data (cmd or data) to port // { int i; for (i=0 ; i<8 ; i++) { if(x & (0x01<<i)) { IOSET0 |= 1<<(i+16); // DB0 - DB7 must be connected to P0.16 - P0.23 // } else { IOCLR0 |= 1<<(i+16); } } } void enablepulse(void) { IOSET0 |= EN; delay(); IOCLR0 |= EN; } void lcdcmd(unsigned char cmd) { outdata(cmd); IOCLR0 |= RS; // select cmd register // enablepulse(); } void lcddata(unsigned char data) { outdata(data); IOSET0 |= RS; // select data register // enablepulse(); } void lcdstring(unsigned char string[]) { int y; for(y=0; string[y]!='\0'; y++) { lcddata(string[y]); } } void lcdinit(void) { IODIR0 |= 0xFFFFFFFF; lcdcmd(0x38); // Function set: 2 Line, 8-bit, 5x7 dots // delay(); lcdcmd(0x0F); //Display on, Curson blinking command// delay(); lcdcmd(0x0E); // Display on cursor on // delay(); lcdcmd(0x01); // Clear LCD // delay(); lcdcmd(0x80); // Choose 1st line // delay(); lcdcmd(0x06); // Entry mode, auto increment with no shift // delay(); } void lcdclear(void) { lcdcmd(0x01); } void lcd1stline(void) { lcdcmd(0x80); } void lcd2ndline(void) { lcdcmd(0xC0); } void gotorowcoloum(unsigned char row, unsigned char coloum) { if(row == 1) { lcdcmd(0x80+coloum-1); } else if(row == 2) { lcdcmd(0xC0+coloum-1); } }
Build output: Build target 'Target 1' compiling lcd.c... lcd.c(94): warning: #1-D: last line of file ends without a newline linking... lcd.axf: Error: L6218E: Undefined symbol main (referred from rtentry2.o). Target not created
Do you feel it is too hard to solve the issues yourself?
How about having a last line that ends without a newline - ever tried to add a newline?
Undefines symbol main? Since you are well read on C programming - can you show us where you managed to hide your main(). Or where did you expect your program to start running?
I am creating header file for 16x2 LCD. Hence it doesn't require main function.
I hope that the code you posted is not intended to go into a header file?!
"Hence it doesn't require main function"
Sure, a header file itself won't have a main() - but a program must!
Lol - well, whatever you think you are doing, the compiler think you are wrong. And the compiler is almost always correct.
If you are creating a library, then you don't need a main(). If you are creating a program, then you need a main() however much you move code and declarations between C and header files.
But you do need to tell the tools that you are building a library and not a "program" - so that they know not to require a main()...
But how we can tell the compiler that I am building library not program?????
Take a look for an obvious name in the Project options...