Digital Input Port

The digital input port is Port C, located at address $1003. Looking at the schematic, you can see that there are eight inputs (numbered 0 through 7); each of them is connected to the power supply through a 47K resistor, and directly to one of the 68HC11 pins (PC0 through PC7, respectively).

We wire it up by connecting a switch between the input and ground (0V). If the switch is turned off, the resistor is able to ``pull'' the HC11 input pin to 5 volts (so it's called a pullup resistor), and if we read $1003 we see a 1 in the corresponding bit. If the switch is turned on, there's a direct path from the pin to ground, so the HC11 is pulled down to 0V. If we read it, we see a 0 in that bit position.

Notice that in this case, there is a path from power, through the resistor, through the switch, to ground. But the resistor limits how much current can flow (and limits it to a pretty low value - 5V/47K is just slightly more than 100 µA.

Now, suppose we have a sensor hooked up to input bit 2, and no other inputs hooked up. If the switch is turned off we'll read $ff (all bits are 1); if it's turned on we'll read $fb (the bit corresponding to that input switch contains a 0).


Last modified: Wed Jan 28 13:06:46 MST 2004