Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

8051 C program errors - misplaced 'unsigned'

Status
Not open for further replies.

muhammedan

Newbie level 4
Joined
Feb 18, 2009
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,309
8051 C program

This program has 2 error what means that?
1-misplaced 'unsigned'
2-character '}' missing
Code:
#include<reg51.h>
void delay(void);
void main (void)
{
unsigned char i,j,k;
TMOD=0x20;
TH1=0;
unsigned char s[60]={0,1,2,3,4,5,6,7,8,9,0x10};
unsigned char m[60]={0,1,2,3,4,5,6,7,8,9,0x10};
unsigned char h[24]={0,1,2,3,4,5,6,7,8,9,0x10};
for(i=0;i<=23;i++)
for(j=0;j<=59;j++)
for(k=0;k<=59;k++)
{P0=s[i];
P1=m[j];
P2=h[k];
delay();
}
}
void delay(void)
{unsigned char z,w;
for(z=0;z<=14;z++)
for(w=0;w<=255;w++)
TR1=1;
while(TF1==0);
TR1=0;
TF1=0;
}
 

try out this code

#include<8051.h>

void delay(void);

code unsigned char s[60]={0,1,2,3,4,5,6,7,8,9,0x10};
code unsigned char m[60]={0,1,2,3,4,5,6,7,8,9,0x10};
code unsigned char h[24]={0,1,2,3,4,5,6,7,8,9,0x10};

void main (void)
{
unsigned char i,j,k;

TMOD=0x20;
TH1=0;
while(1)
{
for(i=0;i<=23;i++)
{
for(j=0;j<=59;j++)
{
for(k=0;k<=59;k++)
{
P0=s;
P1=m[j];
P2=h[k];
delay();
}
}
}
}
}
void delay(void)
{
unsigned char z;
int w;
w=0;
for(z=0;z<=14;z++)
{
while(w<=255)
{
TR1=1;
while(TF1==0);
{
TR1=0;
TF1=0;
}
w++;
}
}
}

please note:-
1. always use {} with all loop and if statements even though u need to execute single statement under it
2.declare all variables before initializing any variale...ur arrays are initialized after tmod and th1.
3.i used int w in delay as w<=255 will always be true for unsigned char type..i gives warning for that...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top