Controlling 8051 output port

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

  1. majoritical

    Thread Starter Member

    Nov 20, 2007
    12
    0
    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
    15,815
    282
    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
    12
    0
    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

    Active Member

    Apr 15, 2008
    471
    0
    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

    Distinguished Member

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

    http://www.atmel.com/dyn/resources/prod_documents/doc4235.pdf

     
  6. TechSpec

    Member

    Jul 9, 2007
    12
    0
    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.
     
Loading...