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.

problem in programming for 8052

Status
Not open for further replies.

robotics_mait

Junior Member level 3
Joined
Jun 5, 2009
Messages
28
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,483
BELOW IS GIVEN THE CODE IN C written in KEIL... and i am trying to execute the program in proteus isis 7 professional...

#include<reg51.h>
#define SENSOR P1

void norm_forw();
void right();
void left();
void stop_wait();
void delay_1s();
void delay_norm();
void wd_forw();

void main()
{

for(;;)
{
switch(SENSOR)
{
case 0xF8:
{
norm_forw();
break;
}
case 0xF9:
{
wd_forw();
break;
}
case 0xFB:
{
right();
break;
}
case 0xFA:
{
right();
break;
}
case 0xFD:
{
left();
break;
}
case 0xFC:
{
left();
break;
}
case 0xFF:
{
stop_wait();
break;
}
default:
{
left();
break;
}
}
}
}
void norm_forw(void)
{
P2=0x0A;
delay_norm();
}
void wd_forw(void)
{
P2=0x0A;
delay_1s();
}
void right(void)
{
P2=0x0B;
delay_norm();
}
void left(void)
{
P2=0x0E;
delay_norm();
}

void stop_wait()
{
P2=0x00;
delay_norm();
}
void delay_norm()
{

}
void delay_1s()
{

}


problem is that the program is all the time for all possible inputs executing same routine in the default statement,i.e,left() .............(this is all going on in proteus not real hardware)

what should be done to solve this?
 

You did not define that you are taking input at P1.

Move 0xFF in this port, for input purpose.
 

yeah but inspite that fact its ready to take the input and moving to the routine in left()

---------- Post added at 14:06 ---------- Previous post was at 13:41 ----------

hey its now working fine... don't know what's the reason .. earlier proteus was not giving the output as expected... but now it is...P1=0xFF was done earlier too... maybe it was a logical error in proteus itself...thanx a lot
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top