my code works well in software simulation but it dont work the same way when tried on hardware
Discussion in "Project Help" started by akshayylr Jan 28, 2018.
Sun Jan 28 2018, 10:23 am
this is my code, this piece gets to work well in software simulation but not on the board.how can i get it working on the board??
#include<reg51.h>
sbit party1=P1^0;
sbit party2=P1^1;
sbit result1=P1^2;
sbit result2=P1^3;
sbit display1=P1^4;
sbit display2=P1^5;
sbit display3=P1^6;
sbit display4=P1^7;
void delay(int max)
{
int i=0,j=0;
for(i=0;i<max;i++)
{
for(j=0;j<12345;j++);
}
}
void main()
{
unsigned int temp1=0,temp2=0,count11=0,count12=0,count13=0,count14=0,count21=0,count22=0,count23=0,count24=0;
int a[]={0x3f,0x06,0x5b,0x4f,0xe6,0xed,0x7d,0x07,0xff,0xef};
while(1)
{
// party1=party2=result1=result2=1;
while(party1==0&&party2==1&&result1==1&&result2==1 )
{
temp1++;
}
while(party2==0&&party1==1&&result1==1&&result2==1 )
{
temp2++;
}
count11=count11+(temp1/temp1);
if(count11==9)
{
count12++;
count11=0;
if(count12==9)
{
count13++;
count12=0;
if(count13==9)
{
count14++;
count13=0;
}
}
}
count21=count21+(temp2/temp2);
if(count21==9)
{
count22++;
count21=0;
if(count22==9)
{
count23++;
count22=0;
if(count23==9)
{
count24++;
count23=0;
}
}
}
temp1=0;
temp2=0;
P2=0X00;
while(result1==0&&party2==1&&party1==1&&result2==1)
{
display1=1;
P2=a[count11];
delay(5);
display2=1;
P2=a[count12];
delay(5);
display3=1;
P2=a[count13];
delay(5);
display4=1;
P2=a[count14];
delay(5);
}
while(result2==0&&party2==1&&party1==1&&result1==1)
{
display1=1;
P2=a[count21];
delay(5);
display2=1;
P2=a[count22];
delay(5);
display3=1;
P2=a[count23];
delay(5);
display4=1;
P2=a[count24];
delay(5);
}
}
}
#include<reg51.h>
sbit party1=P1^0;
sbit party2=P1^1;
sbit result1=P1^2;
sbit result2=P1^3;
sbit display1=P1^4;
sbit display2=P1^5;
sbit display3=P1^6;
sbit display4=P1^7;
void delay(int max)
{
int i=0,j=0;
for(i=0;i<max;i++)
{
for(j=0;j<12345;j++);
}
}
void main()
{
unsigned int temp1=0,temp2=0,count11=0,count12=0,count13=0,count14=0,count21=0,count22=0,count23=0,count24=0;
int a[]={0x3f,0x06,0x5b,0x4f,0xe6,0xed,0x7d,0x07,0xff,0xef};
while(1)
{
// party1=party2=result1=result2=1;
while(party1==0&&party2==1&&result1==1&&result2==1 )
{
temp1++;
}
while(party2==0&&party1==1&&result1==1&&result2==1 )
{
temp2++;
}
count11=count11+(temp1/temp1);
if(count11==9)
{
count12++;
count11=0;
if(count12==9)
{
count13++;
count12=0;
if(count13==9)
{
count14++;
count13=0;
}
}
}
count21=count21+(temp2/temp2);
if(count21==9)
{
count22++;
count21=0;
if(count22==9)
{
count23++;
count22=0;
if(count23==9)
{
count24++;
count23=0;
}
}
}
temp1=0;
temp2=0;
P2=0X00;
while(result1==0&&party2==1&&party1==1&&result2==1)
{
display1=1;
P2=a[count11];
delay(5);
display2=1;
P2=a[count12];
delay(5);
display3=1;
P2=a[count13];
delay(5);
display4=1;
P2=a[count14];
delay(5);
}
while(result2==0&&party2==1&&party1==1&&result1==1)
{
display1=1;
P2=a[count21];
delay(5);
display2=1;
P2=a[count22];
delay(5);
display3=1;
P2=a[count23];
delay(5);
display4=1;
P2=a[count24];
delay(5);
}
}
}
[ Edited Sun Jan 28 2018, 10:25 am ]
Thu Feb 01 2018, 02:27 am
You will have to post your full code and the Proteus file.
Most likely you have a hardware problem, such as a pin not connected.
Most likely you have a hardware problem, such as a pin not connected.
Thu Feb 01 2018, 03:27 pm
You will have to post your full code and the Proteus file.
Most likely you have a hardware problem, such as a pin not connected.ExperimenterUK
This is the full program and can I know what are this Proteus file
Thu Feb 01 2018, 11:30 pm
Your program did not attach.
Zip it before posting.
"can I know what are this Proteus file"
I assumed you were using Proteus software for your simulation.
Post what you can of your simulation so we can try to recreate what you are doing.
Again ,zip it before posting.
Zip it before posting.
"can I know what are this Proteus file"
I assumed you were using Proteus software for your simulation.
Post what you can of your simulation so we can try to recreate what you are doing.
Again ,zip it before posting.
Powered by e107 Forum System