Microcontroller › 8051 › Help with AT89C2051
- This topic has 3 replies, 2 voices, and was last updated 13 years, 9 months ago by Ahmed.
Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
April 16, 2011 at 1:42 pm #868AhmedParticipant
Hi There
I use AT89C2051 to contrall traffic light with PC
my problem is with port1 that P1^0,P1^1 always disabled whene i program the ATMEL but in the Proteus Works good????
what is the reson ????
this is the code
April 20, 2011 at 4:49 am #6006romel emperadoParticipantpls post your code here..
April 21, 2011 at 5:45 pm #6014AhmedParticipantI Use ALL-11P3 Programmer you know
April 21, 2011 at 5:55 pm #6013AhmedParticipantThis is the Code Romel
the delay function can i calculate the time delay by using ((1/11.0592*10^6)*80000)??
or ther is another way to calculate???
/* *********************************************************************************************Project: Traffic Project (COM1)File: Traffic.txtData: 8/4/2011Processor: AT89C2051Program to Controll Traffic with PC with provment of LED********************************************************************************************* */#include<reg51.h>unsigned char temp;sbit trR3=P3^2;sbit trY3=P3^3;sbit trG3=P3^4;sbit trR4=P3^5;sbit trG4=P3^7;sbit trY4=P1^7; // Port Of LED’svoid ini() // Initialize Timer 1 for serial communication{TMOD=0x20; //Timer1, baud rate 9600 bpsSCON=0x50; // 8-BitTH1=0XFD; //Load the timer high with initial value for serial connectionTR1=1; //Start Timer 1}void delay() //simple Delay{int k,l;for(k=0;k<1000;k++)for(l=0;l<80;l++);}void recieve() //Function to receive serial data for controlling{while(RI==0);temp=SBUF;switch(temp) // Sequence Of LED of traffic.{case(‘1’):P1=0x0c;trR3=1;trY3=0;trG3=0;trR4=1;trY4=0;trG4=0;break;case(‘2’):P1=0x12;trR3=1;trY3=0;trG3=0;trR4=1;trY4=0;trG4=0;break;case(‘3’):P1=0x21;trR3=1;trY3=0;trG3=0;trR4=1;trY4=0;trG4=0;break;case(‘4’):P1=0x11;trR3=0;trY3=1;trG3=0;trR4=1;trY4=0;trG4=0;break;case(‘5’):P1=0x09;trR3=0;trY3=0;trG3=1;trR4=1;trY4=0;trG4=0;break;case(‘6’):P1=0x09;trR3=0;trY3=1;trG3=0;trR4=0;trY4=1;trG4=0;break;case(‘7’):P1=0x09;trR3=1;trY3=0;trG3=0;trR4=0;trY4=0;trG4=1;break;case(‘8’):P1=0x0a;trR3=1;trY3=0;trG3=0;trR4=0;trY4=1;trG4=0;break;case(‘0’):P1=0;P1=0x12;trR3=0;trY3=1;trG3=0;trR4=0;trY4=1;trG4=0;delay();P1=0;trR3=0;trY3=0;trG3=0;trR4=0;trY4=0;trG4=0;}RI=0;}void main() //main Program.{ini(); //initialize the microcontrollerwhile(1) // infinit loop{recieve();}} //End of Program -
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.