473,378 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

help me on this C language problem

2
guys,
i have some problem regarding my C programming language. it will appear some error on the bottom. please refer attachment for detailed explanation. please help me.........:)


#include <AT89X51.H>
#define EE_SCL P1_0
#define EE_SDA P1_1
#define LCD_E P1_7
#define LCD_RW P1_6
#define LCD_RS P1_5
#define LCD_DATA P3
#define buzz P0_3
#define led P1_2

void cmnwrt(int);
void datawrt(char);
char keypad_refresh();
void init();
void delay(unsigned i);
void get_sntnc(char *);
void print_msg(char*,char);
void EE_write(unsigned int, char);
char EE_read(unsigned int);
void EE_strt();
void EE_stop();
char EE_shin();
void EE_shout(char);

int main(){
/*
char tmp[17],i,j;
init();
cmnwrt(0x80);
led=1;
while(1);

if(EE_read(0) != 'p' || EE_read(1) != '=')

np:
cmnwrt(1);
print_msg("Enter new pass:\0",0x80);
get_sntnc(tmp);
EE_write(0,'p');
EE_write(1,'=');
for(i=0; tmp[i]; i++)
EE_write(i+2,tmp[i]);
EE_write(i+2,0);


rpa:
cmnwrt(1);
print_msg("Enter the pass:\0",0x80);
get_sntnc(tmp);
for(i=0,j=0;;i++)

if(tmp[i] != EE_read(i+2))

j=-1;
break;

if(!tmp[i])
break;

cmnwrt(1);
if(j==-1)

print_msg("Pass is wrong!\0",0x80);
led=1;
buzz=1;
delay(5000);
buzz=0;
goto rpa;

else

print_msg("Pass is right!\0",0x80);
led=0;
buzz=0;
delay(5000);
led=1;

cmnwrt(1);
print_msg("*=change pass\0",0x80);
print_msg("#=back\0",0xc0);
ka:
do
i=keypad_refresh();
while(i==-1);
if(i==0x3a)
goto np;
else
if(i==0x3c)
goto rpa;
else
goto ka;


//------------------------------------
//------------------------------------
void print_msg(char *msg, char line)

char i;
cmnwrt(line);
for(i=0; *(msg+i); i++)
datawrt(*(msg+i));

//------------------------------------
//------------------------------------
char keypad_refresh()

char tmp,row,cl;
P2 = 0xf0;
if(!P2_4)
row = 0;
else if(!P2_5)
row = 1;
else if(!P2_6)
row = 2;
else if(!P2_7)
row = 3;
else
return -1;
P2 = 0xff;
P2 = 0x0f;
if(!P2_2)
cl = 0;
else if(!P2_1)
cl = 1;
else if(!P2_0)
cl = 2;
else
return -1;
tmp = row*3+cl+1;
if(tmp == 11)
tmp = 0;
return tmp|0x30;

//--------------------------------------------------
//--------------------------------------------------
void get_sntnc(char *str)

char i,j,z;
for(i=0; i<17; i++)
*(str+i) = 0;
i=0;
while(1)

cmnwrt(0xc0);
for(z=0; z<16; z++)
if(*(str+z))
datawrt(*(str+z));
else
datawrt(' ');
delay(70);
do
j = keypad_refresh();
while(j==-1);
if(j==0x3c)

*(str+i) = 0;
break;
else if(j==0x3a)

if(i>0)
i--;
*(str+i) = 0;


else

if(i<=15)

*(str+i) = j;
i++;

//--------------------------------------------------
//--------------------------------------------------
void init()

int i;
P0=P1=P2=P3=0;
//initialize LCD
LCD_RS = 0;
LCD_RW = 0;
delay(30);
cmnwrt(0x3f);
delay(20);
cmnwrt(0x3f);
delay(10);
cmnwrt(0x3f);
delay(5);
cmnwrt(0x38);
cmnwrt(0x01);
cmnwrt(0x0c);
//initialize EEPROM
EE_SDA = 1;
for (i=0; i<10; i++)

EE_SCL = 1;
i=i; //delay
EE_SCL = 0;


//--------------------------------------------------
//--------------------------------------------------
void delay(unsigned i)

TMOD = 1;
for (;i>0;i--) {
TH0 = 0xFc; //0xFFFF - 0xFc17 = 1000 (decimal) -> 1ms for 12MH crystal
TL0 = 0x17;
TR0 = 1;
while(!TF0);
TR0 = 0;
TF0 = 0;


//--------------------------------------------------
//--------------------------------------------------
void cmnwrt(int cmn)

LCD_DATA = cmn;
LCD_RS = 0;
LCD_RW = 0;
LCD_E = 1;
LCD_E = 0;
delay(2);

void datawrt(char ch)

LCD_DATA = ch;
LCD_RS = 1;
LCD_RW = 0;
LCD_E = 1;
LCD_E = 0;
delay(2);

//---------------------------------------------------
//---------------------------------------------------
//Write into EEPROM
void EE_write(unsigned int addr, char dta)

char chtmp;
CY = 0;
EE_strt();
EE_shout(0xA0);
chtmp = addr>>8;
EE_shout(chtmp);
chtmp = addr;
EE_shout(chtmp);
EE_shout(dta);
EE_stop();
delay(13);

//Reading from EEPROM
char EE_read (unsigned int addr)

char chtmp;
CY = 0;
EE_strt();
EE_shout(0xA0);
chtmp = addr>>8;
EE_shout(chtmp);
chtmp = addr;
EE_shout(chtmp);
EE_strt();
EE_shout(0xA1);
chtmp = EE_shin();
EE_stop();
return chtmp;

//Start
void EE_strt()

EE_SDA = 1;
EE_SCL = 1;
EE_SDA = 0;
EE_SCL = 0;

//Stop
void EE_stop()

EE_SCL = 0;
EE_SDA = 0;
EE_SCL = 1;
EE_SDA = 1;

//Shift out
void EE_shout(char sho)

unsigned char i,j;
for (j=0, i=0; i<8; i++)

j /= 2;
if (!j)
j=128;
if (sho&j)
CY = 1;
else
CY = 0;
EE_SDA = CY;
EE_SCL = 1;
j = j; //delay
EE_SCL = 0;

EE_SDA = 1;
EE_SCL = 1;
j=j; //delay
CY = EE_SDA;
EE_SCL = 0;

//Shift in
char EE_shin()

char i,shi = 0;
EE_SDA = 1;
for (i=0; i<8; i++)

CY = 0;
shi <<= 1;
EE_SCL = 1;
i=i;
CY = EE_SDA;
EE_SCL = 0;
if (CY)
shi++;

EE_SDA = 1;
EE_SCL = 1;
i=i; //delay
EE_SCL = 0;
*/
return shi;
}
end
Attached Images
File Type: jpg 12.jpg (138.0 KB, 158 views)
Dec 8 '13 #1
3 1317
weaknessforcats
9,208 Expert Mod 8TB
What's the /* for?

void EE_shout(char);

Expand|Select|Wrap|Line Numbers
  1. int main(){
  2.  /*                      <<<<<<<------!!!
  3.  char tmp[17],i,j;
  4.  
Are you commenting out large amounts of this code?
Dec 8 '13 #2
arefiq
2
yes. i just try and error based on research from internet but still failed. all of the error are commonly illegal statement syntax. now i'm using M-IDE studio for build and sim this language. or u have recommended software that i can use it.
Dec 8 '13 #3
weaknessforcats
9,208 Expert Mod 8TB
This code:
Expand|Select|Wrap|Line Numbers
  1. EE_SDA = 1;
  2.  EE_SCL = 1;
  3.  i=i; //delay
  4.  EE_SCL = 0;
  5.  */
  6.  return shi;
  7.  }
shows the */ that completes the comment. That makes the entire program:

Expand|Select|Wrap|Line Numbers
  1. int main(){
  2.  return shi;
  3.  }
and now shi is not declared.

It might help to tell me what the error is.
Dec 8 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: sKodi | last post by:
I have a problem. When I had IIS 5.1 my Dreamweaver MX created ADODB.Recordset objects for my ASP pages. Everything worked great. But now it causes HTTP500 - Internal Server Error. What's up?
11
by: milkyway | last post by:
Hello, I have an HTML page that I am trying to import 2 .js file (I created) into. These files are: row_functions.js and data_check_functions.js. Whenever I bring the contents of the files into...
3
by: Richard | last post by:
I am trying (for first time) to get Yuan Heng's JSCookMenu to work. I have placed "JSCookMenu.js" in the main web directory (ie. in http://xyz.com/) , and created a folder called ThemeIE (ie....
4
by: eap90210 | last post by:
Hi to all ng I 'm a non expert user og db2 and i made a program that it connect to db2 and after goes to a table, verify that exists a value and after return success or not. My problem is...
1
by: arbowen | last post by:
My hard drive would not function to bring up Windows 98. I purchased a new computer using Windows XP. The database files from the old hard drive were copied into an "old computer files" folder on...
2
by: Ivan V via DotNetMonster.com | last post by:
Dear All: I am not sure this is the right place to ask this question, but I hope someone can help me out of that. I have a set of data which is in dbf format and need to import into my SQL2000...
2
by: =?Utf-8?B?U2hvb3Rlcg==?= | last post by:
Hi, We have an MCMS Site displaying content in ten different languages. The problem is that when any other language is being used bar english the title which is set to a placeholder is...
2
by: Abdo389 | last post by:
i have a problem in Arabic language. i read Arabic string from text file and write it in excel sheet but Arabic text written into excel as garbage and unknown word .this problem in encoding.please i...
1
by: H-S | last post by:
Help! I am trying to use the Windows.Controls.TextBox with spellcheck turned on. It works fine if my keyboard input language is set to English (United States). But the spellcheck starts to get...
4
by: everurssantosh | last post by:
Hi, I am trying to show five different languages in my website. I am not using any other tool to achieve this task. Basically, I have stored the all language values in a language file. While in my...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.