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.

define port P0 and define Pin1 P0^0

Status
Not open for further replies.

vead

Full Member level 5
Joined
Nov 27, 2011
Messages
285
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
india
Activity points
3,815
define statement is use for constant value

#define TRUE 1
#define FALSE 0


what is difference between define port P0 and define Pin1 P0^0 ?

Code:
#include <reg51.h>

#define port P0 

#define Pin1  P0^0  
#define Pin2  P0^1  
#define Pin3  P0^2 
#define Pin4  P0^3  

char value(void)
{
   unsigned char value;
   
   char i;
   
   for (i=0; i<4; i++)
	   
	   {
		  value = 0x1110 1111;
                  if(!Pin1) valueReturn = A;
                  if(!Pin2) valueReturn = B;
                  if(!Pin3) valueReturn = C;
                  if(!Pin4) valueReturn = D;
            
                  value <<= 1;
         
		  value ++;    
       }        
    return valueReturn;
}
 

what is difference between define port P0 and define Pin1 P0^0 ?

The P0 statement represents a byte that maps all 8 pins of the port P0, whereas P0^0 represents a bit ( actualy the pin 0 of the port P0 ).
 
  • Like
Reactions: vead

    vead

    Points: 2
    Helpful Answer Positive Rating
if (a != 0)
mean's 'if a is not equal to zero'.

what is meaning of if(!Pin1)
 

Different functions:

  • ! NOT opperator ( logic inverse of the variable at right side )
  • != inequality evaluation ( returns true if both sides are different )
 

Different functions:

  • ! NOT opperator ( logic inverse of the variable at right side )
  • != inequality evaluation ( returns true if both sides are different )

I know that but I don't understand if(!Pin1) in program
 

I know that but I don't understand if(!Pin1) in program

Code:
if ([I]condition_is_true[/I])
   {
   do_this();
   }
else
   {
   do_that();
   }
Were:
  • condition_is_true => !Pin1
The above condition is true when Pin1==0
 
  • Like
Reactions: vead

    vead

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top