Show pageOld revisionsBacklinksExport to PDFBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== I/O on the 8051 ====== The 8051 has 4 GPIO 8-bit ports. ===== Output ===== To write an output to a port, just move some data to that port's register. <code asm> mov P1, A ; Output the contents of the accumulator on port 1. </code> Individual bits of ports can also be set or cleared. <code asm> clr P1.0 ; Output high on the 0th pin of port 1. setb P1.0 ; Output low on the 0th pin of port 1. </code> ===== Input ===== **Before reading from an input pin, the pin MUST be set to high in order to prevent a short circuit.** After setting the pins to high, the inputs can be read by reading the port's register. <code asm> mov P1, #0FFh ; Set all pins of port 1 to high. mov A, P1 ; Move the input data on port 1 to the accumulator. </code> kb/8051_io.txt Last modified: 2024-04-30 04:03by 127.0.0.1