Controlling 8051 output port

Discussion in 'Embedded Systems and Microcontrollers' started by majoritical, May 1, 2008.

  1. majoritical

    Thread Starter Member

    Nov 20, 2007
    Hi guys,

    I am trying to switch between various outputs on port 1 of an 8051, based on

    data the 8051 receives from an external EPROM.

    Now regardless of what I do, a LED connected to P1.0 is constantly high.

    I even sent a low to it by changing the microcontroller code, but its still high.

    How exactly do I controll the port 1 outputs. Sample code and (or)

    schematics will be highly appreciated.

    My code is available on request.

    Thanks a bunch in advance!!!!
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    You will have to be more clear. Vanilla 8051's do not have ports, just address and data lines. Your microprocessor is probably based on an 8051 core, but we don't know what it is.

    If you just used the output line to drive the LED with no current limiting, then that line is bad now. It's a good idea to understand all the hardware before using it.
  3. majoritical

    Thread Starter Member

    Nov 20, 2007
    I'm using an Atmel AT89C51ED2. I'm trying to drive the LED's from port 1 (if thats right??).

    Basically the LED's are for testing, to see if my code is working well. If that works, i intend on using some drivers to 'drive' a relay from the microcontroller.

    Hope that clarifies things a bit.
  4. Caveman

    Senior Member

    Apr 15, 2008
    This is a general statement without reading your processor's datasheet (which you should do. Yes, all of it!).

    You need to make sure that the port is set to be an output first. This is typically done using an direction register. Then you have to drive the port register low.
  5. mrmeval

    AAC Fanatic!

    Jun 30, 2006
    It's odd compared to other atmel products.

  6. TechSpec


    Jul 9, 2007
    8051 processors dont have direction registers. You simply set the port to 1 or 0 by P1.1=0 or P1.1=1, at the same time you can read the port aswell.
    Driving a led is simple, just add resistor in series and pull cathode low.