When the P1 and P3 ports of the MCU are used as the input ports, why should 1 be written to the port

Updated on technology 2024-02-27
10 answers
  1. Anonymous users2024-02-06

    The P1 port can be input and output.

    P1 port is used as an input port, how to use it?

    Which instruction should be used as an input port, and how can it be used as an input port, is it up to us to imagine?

    Some microcontrollers will have a register to set whether the io port is input or output, but this one does not.

    So how do you make this an input or an output?

    There is a latch on each port that locks the value that was previously written.

    For example, if there is only a pull-up resistor connected to the port, this port should be high level as input.

    Then you write a 0 in the mouth, and the mouth will output 0, and the mouth will become low.

    At this time, if you read this io port, it will also be low.

    If it is not rewritten to 1, the latch will always be 0, that is, the output is 0, and the level on the program reading port is also 0.

    After rewriting to 1, the level on this mouth will be 1, or in other words, it will not pull this mouth down.

    When it is used as an input port, you need to write 1 in advance, or you don't need to write it every time, as long as it is not 0 inside.

    The one who scans the keyboard,Assign,0xfe is equivalent to,Write 1 in the upper 7 bits of the P1 port,Write 0 in the lowest bit,That is, P10 outputs 0,Then read the high 4 digits,See if there are any keys。 Next, the 0xfd is P11 output 0, which is also read 4 bits high, to see if there are buttons in the row of P11.

    This is written as 1, not p17=1 is called writing 1, p1=0xfe The overall assignment is also written as 1. Just write 1 in the mouth you want to read.

  2. Anonymous users2024-02-05

    This is due to the structure of the P1 P3 port. When the microcontroller performs the read pin operation, if the data originally registered in the latch q=0, then because the non-q=1 will make v on, the pin will be clamped low, and even if the level of the external circuit is 1, the result of the read pin is 0

    Therefore, when P0 and P3 ports are used as input ports, 1 should be written first

  3. Anonymous users2024-02-04

    The problem is very simple, it is not easy to explain, the reason is that P0 and P3 are both quasi-two-way ports, why? It depends on the four parallels.

    The mouth structure diagram is understood.

    What is called quasi-bidirectional, that is, the P0 P3 output is fine, but the input is not. Just like our common doors, they open outward, without a zipper, and are pulled by a spring. When you go out, the door opens, and when you come in, you have to reach out and pull the door anyway.

    The action of pulling the door is to write 1 to the px mouth first.

    The purpose is to make the FET.

    The drain and source are truncated at a low level. The input level signal can be correctly applied to the microcontroller. Read out.

  4. Anonymous users2024-02-03

    There are two kinds of triggers for the button, one is the low level trigger and the other is the edge trigger, both of which are under the premise of high level, so the value should be assigned to 1. This 1 is not what you think it is, it just constitutes a trigger.

  5. Anonymous users2024-02-02

    When the P1 port of the single-chip microcomputer is used as a general-purpose input and output, what are the three working modes.

    When the P1 port of the single-chip microcomputer is used as a general-purpose input family output, what are the three working modes Hello dear, 8255 has three working modes Mode 0 (basic input and output mode): There is no need to select any signal signal, A port, B port, high half C port, low half C port, can be set as input or output. When the output port is used, the output data is locked; The input data is not locked when it is used as an input port.

    Method 1 (strobe input and output mode): The three ports A, B, and C are divided into two groups. Group A includes A port and high half C port, A port can be programmed to input or output, high half C port is used for I O control and synchronization signal; Group B includes B port and low half C port, B port can be programmed to input or output, low half C port is used for IO control and synchronization signal; The input and output data of port A and port B are all locked.

    Method 2 (bidirectional bus mode): A port (only brother guess A port) is used as 8-bit bidirectional bus, and PC3 and PC7 bits of C port are used as I-O control and synchronization signals; PC0 and PC2 of B and C ports can be programmed to work in mode 0 or mode 1. I hope I can help you.

    If my answer is helpful to you, please also give a thumbs up (comment in the lower left corner), I look forward to your like, your efforts are very important to me, and your support is also the motivation for my progress. Finally, I wish you good health and a good mood!

  6. Anonymous users2024-02-01

    P-port? It's P1, P2, P3, P0 don't need to. Also, you're talking about 51 single-chip microcontrollers;

    Okay, let's look at the circuit interface of a pin of the P1 port above, the port is used as an input, that is, it is to read the level status of the change pin, therefore, the MOS tube must be disconnected, otherwise no matter whether the signal from the pin is high or low, it will be read out at a low level, because it is grounded at this time; Then to disconnect the MOS tube, Q must be 0; Therefore q must be = 1,; So s must be = 1, that is, the internal bus should write 1

  7. Anonymous users2024-01-31

    The p0 of 51 is open leakage, and the other is a weak pull-up quasi-two-way port, think about it with the knowledge of digital electricity.

  8. Anonymous users2024-01-30

    Don't write 1? You write 0 words. Doesn't it become 0 if you enter a 1 signal? In other words, whatever signal you input is 0

  9. Anonymous users2024-01-29

    It is a quasi-bidirectional port special structure of 51, and other single-chip microcomputers do not have this statement.

  10. Anonymous users2024-01-28

    My understanding is that generally valid signals are 0 and are easy to find after pulling up.

Related questions
4 answers2024-02-27

You use a P1 port to control the dynamic scanning of 8 digital tubes, and the dynamic scanning display of digital tubes needs to be blanked. >>>More

8 answers2024-02-27

void key0()

if(p1_0!=1) *If the key 0 is pressed. >>>More

12 answers2024-02-27

A: The bit-addressing area is located between 20F and 2Fh in the data memory. The registers in this interval can be bit-addressed, and they can be bit-manipulated and bit-arithmetic. >>>More

6 answers2024-02-27

In this case, it depends on sp, ret is equal to (sp) pch, sp-1 sp (sp) pcl, sp-1 sp >>>More

16 answers2024-02-27

Isn't this thing just a digital tube displaying 16 digits? Prompt you 16 times to get there, let go after you think to press the stop button. If so, the procedure is available for reference: >>>More