Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/26/08 09:09
Read: times


 
#160310 - Using 8051 port as output.
Responding to: ???'s previous message
You need to look at an standard 8051 as a microcontroller with pull-up resistors.

If you read a port, you read the effective levels on each port pin.
If you write a port pin high, it does nothing. i.e. the external pull-up resistor is the only thing that may pull up the output level.
If you write the pin low, it will SINK current.

So you always connect LEDs etc as active low.
You can never expect any SOURCE current although the circuitry does try to assist the switching rise and fall times.


// AVR pseudo code
// DDRB.1 = 1;     // make output
// PORTB.1 = 1;    // SOURCE current
// PORTB.1 = 0;    // SINK current
// DDRB.2 = 0;     // make input
// key = PINB.2;   // read level ( needs external or internal pull-up )

// 8051 pseudo code
// P1.1 = 0;       // SINK current
// key = P1.2;     // read level ( needs external pull-up )

 


In practice the 8051 outputs are easier to use, but do require that you design for active low logic.

You can "port" between cpu types quite easily with a few well chosen macros:
e.g. #define SET_DDR(port, pin, level)   // expands to nothing

 


David.

List of 8 messages in thread
TopicAuthorDate
AT89S8253's port bits in C            01/01/70 00:00      
   What Compiler?            01/01/70 00:00      
      8051s don't have any port direction settings.            01/01/70 00:00      
   RE: I can't find it anywhere            01/01/70 00:00      
   Using 8051 port as output.            01/01/70 00:00      
      Such a #define lies to the user            01/01/70 00:00      
         Point Taken            01/01/70 00:00      
            8051 cannot perform as a SOURCE            01/01/70 00:00      

Back to Subject List