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.

all the parallel ports not working in p89v51rd2 (8051)

Status
Not open for further replies.

cse_muthu

Newbie level 3
Newbie level 3
Joined
Feb 23, 2013
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,321
hi,
i am new to embedded programming. after i flashed a serial program to make serial communication between two 8051 MCUs in both of my MCU, the parallel ports(P0,P1,P2,P3) are not working. even after flashing a new program no output in any port of both the MCUs.
the code i have used in sender 8051 is
given below :

#include<REG51.h>
unsigned char a;
int i;
void front()
{
unsigned char b=0x0a;
SBUF=b; //place value in buffer
while (TI==0); //wait until transmitted
TI=0;
}
void back()
{
unsigned char b=0x05;
SBUF=b; //place value in buffer
while (TI==0); //wait until transmitted
TI=0;
}
void left()
{
unsigned char b=0x02;
SBUF=b; //place value in buffer
while (TI==0); //wait until transmitted
TI=0;
for(i=0;i<=10;i++);
SBUF=0x00; //place value in buffer
while (TI==0); //wait until transmitted
TI=0;
}
void right()
{
unsigned char b=0x08;
SBUF=b; //place value in buffer
while (TI==0); //wait until transmitted
TI=0;
for(i=0;i<=10;i++);
SBUF=0x00; //place value in buffer
while (TI==0); //wait until transmitted
TI=0;
}
void stop()
{
unsigned char b=0x00;
SBUF=b; //place value in buffer
while (TI==0); //wait until transmitted
TI=0;
}
void fire()
{
unsigned char b=0x00;
SBUF=b; //place value in buffer
while (TI==0); //wait until transmitted
TI=0;
}
void off()
{
unsigned char b=0x00;
SBUF=b; //place value in buffer
while (TI==0); //wait until transmitted
TI=0;
}
void main()
{
P0=0xff;
P2=0x00;
P1=0x00;
P0=0x00;
TMOD=0x20; //use Timer 1, mode 2
TH1=0xFD; //9600 baud rate
SCON=0x50;
TR1=1;
while(1)
{
a=P0;
if(a==0x01)
{
front();
}
else if(a==0x02)
{
back();
}
else if(a==0x03)
{
left();
}
else if(a==0x04)
{
right();
}

else if(a==0x05)
{
stop();
}
else if(a==0x06)
{
fire();
}
else if(a==0x07)
{
off();
}
else
stop();
}
}




The above program not worked for me.


the receiver side program is
given below:

#include <reg51.h>
void main()
{
unsigned char mybyte;
TMOD=0x20; //use Timer 1, mode 2
TH1=0xFD; //9600 baud rate
SCON=0x50;
TR1=1; //start timer
while(1)
{ //repeat forever
while (RI==0); //wait to receive
mybyte=SBUF; //save value
P0=mybyte; //write value to port
RI=0;
}
}



the receiver side program also not working.


i cant find any problem.
even after erasing all flash in two 8051s,the new program that flashed for checking port also not working.
the new program that i used is given below.

#include<reg51.h>
void main(void)
{
while(1)
{
P0=0xFF;
}
}

the above program doesn't give any output on port0 pins.
the two mcus are not responding to even very simple program like above.
any software reset should be done.
I also attached the project source files in this thread. link to the source file: View attachment keil.rar
i really need help to resolve this issue.
 
Last edited:

no you are not wrong. i also used the code for other ports also. not working. any suggestions?
 

I´m not sure if you understood the neeed to debug the problem at the lower level.
Anywaym try to invert values and see if output invert :

Code:
P0=0x00 ;


+++
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top