#include <regx51.h> // standard 8051 defines // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=- Include files -=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #include <lcd.h> #include <utils.h>
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=- Hardware Defines -=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sfr DATA = P0; sbit OUT1 = P3^4; sbit OUT2 = P3^5; sbit OUT3 = P3^6; sbit OUT4 = P3^7;
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=- Variables -=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= char buf[20]; char code M1[] ="SPEECH: ONE"; char code M2[] ="SPEECH: TWO"; char code M3[] ="SPEECH: THREE"; char code M4[] ="SPEECH: FOUR"; // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=- Main Program -=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= void main() { unsigned char lastdata, datanow; // -=-=- Intialize variables -=-=-= OUT1 = 0; OUT2 = 0; OUT3 = 0; OUT4 = 0; // -=-=- Intialise -=-=-= lcdInit(); // -=-=- Welcome LCD Message -=-=-= lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint("Speech Test"); lcdGotoXY(0,1); // 2nd Line of LCD lcdPrint("System"); delayms(5000); // 5 sec lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint("Train: 1-4 key >"); lcdGotoXY(0,1); // 2nd Line of LCD lcdPrint("Train>Speak Now"); // -=-=- Program Loop -=-=-= lastdata=0xff; while(1) { datanow=DATA; // read data from speech board
if(lastdata!=datanow) // if there is new data then, { lastdata=datanow; switch(lastdata) { case 0x55: lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint("Speech too Long"); lcdGotoXY(0,1); // 2nd Line of LCD lcdPrint("Try Again!"); break; case 0x66: lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint("Speech too Short"); lcdGotoXY(0,1); // 2nd Line of LCD lcdPrint("Try Again!"); break; case 0x77: lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint("No Match"); lcdGotoXY(0,1); // 2nd Line of LCD lcdPrint("Try Again!"); break; case 0x01: if(OUT1==1) OUT1 = 0; else OUT1 = 1; lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint(M1); break; case 0x02: if(OUT2==1) OUT2 = 0; else OUT2 = 1; lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint(M2); break; case 0x03: if(OUT3==1) OUT3 = 0; else OUT3 = 1; lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint(M3); break; case 0x04: if(OUT4==1) OUT4 = 0; else OUT4 = 1; lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint(M4); break; } } } }
is it a correct program? and what is utils.h?
now these errors are coming into picture compiling voice.c... voice.c(6): warning C318: can't open file 'utils.h' VOICE.C(38): warning C206: 'lcdInit': missing function-prototype VOICE.C(40): warning C206: 'lcdClear': missing function-prototype VOICE.C(41): warning C206: 'lcdGotoXY': missing function-prototype VOICE.C(41): error C267: 'lcdGotoXY': requires ANSI-style prototype voice.c - 1 Error(s), 4 Warning(s).
So - you have picked up some random source code somewhere.
Most probably you have a school project and figured that the code you found seems to be close enough to your task so you want to hand it in and save lots of time.
But one thing with code you have found - you need to understand it. Another thing - you need to make sure you get the complete code. the lcd.h and utils.h files aren't part of the C language but are most probably either extensions supplied by a tool vendor or a library vendor or are written by the same person who wrote the main source file.
Before you have these lcd.h and utils.h files in your configured include path, "your" code will not compile.
So provide a suitable function prototype, then!
You do know what a function prototype is - don't you...?
The prototype (in the style defined by the ANSI standard) is not optional - it is required