Set port1 pins as 0 or 1

Thread Starter

mrkrishnan

Joined Feb 13, 2012
4
Dear all,
i am using P89V51RD2 (philips) 8051 micro-controller. i am doing some samples with NSK developemnt kit. In this i want to set the Port1 pint 0 to 7 as high/low continiously. I tried this by using the following lines,

P1 = 0x00 ;
delay(10000) ;
P1 = 0xFF ;

but still i am always getting around 5V on these pins. i searched lot of forums, but in that also they mentioned like this only. Kindly give your suggessions.......


Thanks and Regards
Radhakrishnan M
 

be80be

Joined Jul 5, 2008
2,072
Your code needs to be some thing like this

Rich (BB code):
#include <REGX51.H>
void msdelay(unsigned int );
void main(){
P1=0×00;  //all pin of PORT1 declared as output
//infinite loop
while(1){
P1=0xFF;   //all pin high
msdelay(1000);    //delay
P1=0×00;   //all pin low
msdelay(1000); //delay
}
}
//delay function
void msdelay(unsigned int value){
unsigned int x,y;
for(x=0;x<value;x++)
for(y=0;y<1275;y++);
}
This is in C using Keil uVision4
 
Top