how does processor understand that port pin is high or low?

Discussion in 'General Electronics Chat' started by vead, Mar 30, 2014.

  1. vead

    Thread Starter Active Member

    Nov 24, 2011
    621
    8
    micro controller contain mainly ALU, control unit

    Processor take information from ROM, RAM, Input port

    fetching - decoder take command from rom memory

    decode - decoder decode instruction and tell the cpu what to do like add, sub

    execution- alu do the operation like add, sub.. and sand the result into ram memory

    processor take input from the input port
    Input are the signal or data received by the processor
    output are signal or data sent from it


    I don't want to someone explain whole things
    but can you give hint its lots for me
    I have many doubts, but at this time the main doubt I have that signal from the input device(switch) goes into the input port

    Q. 1 how does processor know that which port pin is high and which port pin is low ?

    same for output device (LED) signal come from port ?

    Q.2 how does processor send the signal to output port ?
     
  2. Robin Mitchell

    Well-Known Member

    Oct 25, 2009
    732
    200
    Here is a hint. Look up any standard PIC datasheet and read chapters related to IO (like IO pins for example). They include the schematics for most parts!

    Have fun!
    Robin
     
  3. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,790
    #1. The input is like a voltage compare circuit with two thresholds. In a data sheet these voltages are VIH (Voltage, Input High) and VIL(Voltage, Input low). Any voltage greater than VIH is a high or a "1". Any voltage less than VIL is a low or a "0". Any voltage in between is in no mans land and could be either high or low. In practice the transitions between high and low should occur relatively fast. Keeping inputs out of "no mans land" is why unused inputs need to be tied high or low.

    #2. An output is connected to either the Vcc supply or to ground through a transistor switch. If the output is high it can supply a certain amount of current before the voltage stars to sag or droop. VOH (Voltage, Output High) is the guaranteed voltage level at which a certain amount of current will be supplied. It is the minimum output high level. If the output is low then it can sink a certain amount of current up to to some voltage. VOL (Voltage, Output low) is the maximum output voltage in the low state while the output is sinking a given amount of current.

    Is that about what you expected?
     
    vead likes this.
  4. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,790
    There is no evidence that he can actually do this without some guidance.
     
  5. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,052
    3,817
    Q1. As far as I know, the Microcontroller sets a port pin high or low based on input logic. The Microcontroller has NO feedback mechanism to "know" if a pin is actually putting out a high or low signal. The actual setting of a port pin will depend on whether a port pin is high, low or set to a high impedence input state all depend on the many cascades of control logic associated with that pin. Even if it is an input, what kind of input is is? Analog or digital. If digital, what threshold voltage is considered high vs low. Depending on the features of your Microcontroller, some can be adjusted and some cannot.

    It all gets very complicated, doesn't it?
     
  6. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,790
    Ahhh...beg to differ. All microcontrollers can read the value on a pin and determine if the output is what it is supposed to be.
     
    GopherT likes this.
  7. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,052
    3,817
    Ok, thank you.

    I just read the following and now see the detail difference between PORT and LAT on a PIC. (Figure 11-1). There was always a gap for me as to what the difference was. Now I know.

    http://ww1.microchip.com/downloads/en/DeviceDoc/70058D.pdf
     
    Papabravo likes this.
  8. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,790
    Even the long in the tooth 8051 with the "quasi bi-directional" port could tell if an output was where it was supposed to be. We've come a long way since the 8051 first appeared in 1978.
     
  9. vead

    Thread Starter Active Member

    Nov 24, 2011
    621
    8
    I am not sure but Think signal from the switch (input) goes input port which is addressed any other memory location in Ram memory
    program in rom memory tell the processor to look at location and if the switch is open 0000 the location will hold 0000 data and If switch is closed 0001 location will hold 0001 data


    RAM memory -- ROM memory
    location -- address data
    R0:8000 -- 8000 0000 switch is open
    R1:8006 -- 8006 0001 switch is closed
    !
    !
    ! ! !
    R20 -- 8010 0010

    program contain both data and address in rom memory processor read the memory instruction 8000 0000

    Decoder decode the instruction

    processor do the arithmetic and logic operation

    program tell the processor look at location and If switch is open 0000 the location 8000 will hold data 0000 and If switch is closed the location 8006 hold the data 0001

    program counter execute instruction one by one
     
  10. Robin Mitchell

    Well-Known Member

    Oct 25, 2009
    732
    200
    Your right, I completely forgot about this guys previous posts. But if you are using micro-controllers you gotta have some basic understanding in electronics. For example I only started using uC's when I understood a lot about combinational logic, layout of CPUs, analogue electronics etc. I think jumping in with two feet can do more harm than good, better to build up (but thats what I have experienced and im sure there are others who disagree).

    All the best,
    Robin
     
    Papabravo and tshuck like this.
Loading...