output vs. dir
basicstampede
Posts: 214
What is the difference between the following?
1.··High 4
2.· Out4 =1
···· Output 4
3.· Out4 = 1
···· Dir4 = 1
Is there a subtle difference between case 2 and 3 above or are they identical?
·
1.··High 4
2.· Out4 =1
···· Output 4
3.· Out4 = 1
···· Dir4 = 1
Is there a subtle difference between case 2 and 3 above or are they identical?
·
Comments
This means that the I/O pins have a register, which indicates for each pin whether it's an INPUT or an OUTPUT. They have a SECOND register, which is where the output states of the pins are stored. If a pin is set as INPUT, then it's output state value is not sent anywhere.
So: 1. HIGH 4 -- this makes I/O pin 4 into an OUTPUT, and then sets the value to HIGH.
2. Out4 = 1 ' This sets the value of the output latch to 1
Output 4 ' This sets I/O pin 4 to an output -- which routes that earlier '1' to the output pin.
3. Out4 = 1
Dir4 = 1 ' This all does the same as #2 above.
The BS1 has 16 bytes (8 words) of RAM space arranged as shown in the table below. The first word, called PORT, is used for I/O pin control. It consists of two bytes, PINS and DIRS. The bits within PINS correspond to each of the eight I/O pins on the BS1. Reading PINS effectively reads the I/O pins directly, returning an 8-bit set of 1's and 0's corresponding to the high and low state of the respective I/O pin at that moment. Writing to PINS will store a high or low value on the respective I/O pins (though only on pins that are set to outputs).