Please Help-New to 8051!!

Discussion in 'Embedded Systems and Microcontrollers' started by tarun31, Jan 11, 2012.

  1. tarun31

    Thread Starter New Member

    Jan 11, 2012
    3
    0
    Hi Guys,
    I am a bit new to the 8051 microcontroller..i have a basic question to ask. Whenever we are using a pin as a input we have to write a 1 to the i/o register. Now this will make the pin an input and due to the internal pull up resistor this pin will also become high when configured as an input. Now if i wanted to read a high input on this pin how can i do it(without using any gates)???? really confused please help..????
     
  2. sach_blue

    New Member

    Jan 11, 2012
    1
    0
    hi, you can read status of pin by reading port register. The port must be programmed by writing 1 to all the bits. Writing 1 will enable input. you should refer internal pin diagram.
    Below is the program to read status of pins
    MOV A,#0FFH ;A=FF hex
    MOV P0,A ;make P0 an i/p port
    ;by writing it all 1s
    BACK: MOV A,P0 ;get data from P0
    MOV P1,A ;send it to port 1
    SJMP BACK ;keep doing it
    You can read tutorials from
    http://embeddedcraft.org/8051tutorials.html#top
     
  3. jimkeith

    Active Member

    Oct 26, 2011
    539
    99
    Now if i wanted to read a high input on this pin how can i do it(without using any gates)????
    If nothing is connected to the input, it will read a logic high. Any logic device driving the input must overcome the pullup resistor current to output a logic low.

    The internal pullup resistor current is easily handled by the logic output that is driving the uC input pin. Depending upon which port is being used, there are two pullups that are turned on simultaneously--one is a strong, high-current pullup (perhaps 20mA) that turns on for only 1 clock cycle--it enables the output to make a fast transition from low to high even when there are numerous capacitive loads (gate inputs) connected--the other pullup is a weak pinch resistor source that runs perhaps 100uA that is intended to be strong enough to keep the input high after the strong pullup is turned off a clock cycle later.

    When configured as an input, only the weak pullup is present.

    Port0 is different as it is intended for tri-state applications where it is normally used for outputting addresses and reading memory (input)--the strong pullups function for one clock cycle, but there are no weak pullups present--if you scope these pins while in operation, the voltage floats all over the place and looks very scary because the signal here is valid only during the read or write cycles. If port0 is not being used for memory, and you want a high impedance input that does not have a pullup resistor, use port0. If driving a port0 pin via an open collector driver, you must add your own pull-up resistor.

    Hope this is clear--kind of tough to explain--there is a section on the hardware port structure in the manual--it is accurate, but tends to be confusing until you figure out what they are getting at.

    Note that logic outputs are always good at sinking current to common (output = logic low), but sometimes are poor at sourcing current (output = logic high). Open collector outputs cannot source current at all, but are very handy for interfacing logic signals from linear devices (e.g. comparators) to logic inputs.
     
    Last edited: Jan 11, 2012
  4. tarun31

    Thread Starter New Member

    Jan 11, 2012
    3
    0
    @jimkeith still kinda confused....see my problem is that when i make a port an input port it becomes high ....now suppose i have a switch connected to it which makes the pin high when pressed then how do i recognise that the pin has become high due to the pressing of the switch...becuase the pin is already high.


    and @sach_blue.... i haven learnt assembly man...i'm coding in c.....
     
  5. jimkeith

    Active Member

    Oct 26, 2011
    539
    99
    Your logic needs to be inverted--use a normally closed switch going to ground--when button is pressed, the circuit opens and the voltage goes high by virtue of the pull-up resistor.

    Inverted logic is common around micros--so much that most do not realize or even have to think about it.
     
  6. srikanth977

    New Member

    Jan 12, 2012
    3
    0
    I am trying to start with dot matrix display with 8051, I have done all the hardware by proteus software.

    The rows I have connected to port 0 with external pull up resistors( 10k).
    the columns are connected to a resistor array and then to the display.

    I am using 5*7 display.
    I want to start by displaying "A" on it.
    and till now I could only display only one light as shown below
    ___________
    | | |O| | |
    -------------
    | | | | | |
    -------------
    | | | | | |
    -------------
    | | | | | |
    -------------
    | | | | | |
    -------------
    | | | | | |
    -------------
    | | | | | |
    -------------


    Please Help me the code.
     
  7. jimkeith

    Active Member

    Oct 26, 2011
    539
    99
    @srikanth977
    I question your hardware--please provide schematic
    You may not be able to drive the display in the manner you indicated.
     
Loading...