Next in our series of the SX Data sheet is the I/O. There is a lot to cover here, so it may end up being a couple posts. First, look at page 3 of the SX20/SX28 data sheet for an overview of the I/O functions.
Flexible I/O
• All port pins individually programmable as I/O
• Inputs are TTL or CMOS level selectable
• All pins have selectable internal pull-ups
• Selectable Schmitt Trigger inputs on Ports B and C
• All output pins capable of sourcing/sinking 30 mA
• Port A outputs have symmetrical drive
• Analog comparator support on Port B (RB0 OUT, RB1 IN-, RB2 IN+)
• Selectable I/O
There are a lot of terms here that you may be unfamiliar with. Or maybe you heard them, but you are not sure what they mean. Flip in the data sheet to page 9. Page 9 to 12 of the data sheet covers the Ports of the SX. More specifically it is the I/O Ports. The Wikipedia article is good. Besides I/O port, this could also be called I/O or I/O registers (which are multiple registers).
I am sure when you read the top description on page 9 of the I/O ports you will be even more confused. One of the first things to recognize is that the I/O ports are made up of multiple 8-bit registers. Another thing to recognize is that each of these registers has a known, default state at power up. So what are the registers?
The diagrams on page 9 and 10 show the detail about the registers. There is a direction register. The bits in this 8-bit register determine the direction of each I/O line. If the least significant bit (bit 0) is a 1, then the corresponding I/O pin on that port is an input. If the least significant bit is a 0, then the I/O pin is an output. As stated in the data sheet, all I/O registers are initialized to 1 on power up. That means that all I/O pins are inputs at the moment the SX is first powered on. The software you write on the SX will change the pins to be outputs. (side note: Port A is only 4 bits while Port B and C are 8-bits and Port C is on the SX28 and not the SX20)
Another register that can be configured is the Pullup Enable Register. This register configures the pin with an ~20K ohm resistor tied to Vdd. This function is valuable when using the pin as an input. Usually there are external pullup resisters, but because this port has the ability to pullup, we can eliminate some external devices. A future post on switches will cover the pullup concept further.
The other register to mention is the TTL/CMOS selectable register. Usually a device is TTL or CMOS compatible. TTL and CMOS are construction techniques for chips and the different techniques determine the different operating characteristics of the device. If you jump forward to page 41 of the data sheet and review the middle part of the page you will see how the SX handles the I/O differently based on the selection in this register. If the chip is in TTL mode (default at power up) then the input will be on or 1 if the voltage on the pin is higher than 2.0V DC. It will be off or 0 if the voltage is below 0.8V DC. The region in between 0.8V and 2.0V is called the hysteresis because sometimes the input is on and sometimes it is off in this region. The hysteresis is undefined state and you should avoid having inputs “hang out” in this region because you will get erractic inputs.
There is much more to learn here, stay tune for another post.