monitor the activities of the key and sends scan code accordingly. three types
of key activities are observed:
1. when a key is press, the make code of the key is transmitted
2. when a key is held down continuously, a condition known as typematic, the
make code is transmitted repeatedly at a specific rate. by default, a ps2
keyboard transmits the make code about every 100 ms after a key has been
held down for 0.5 second.
3. when a key is release, the break code of the key is transmitted.
the make code of the main part of a ps2 keyboard is show in figure 3. it is
normally 1 byte wide and represented by two hexadecimal number. for
example, the make code of the A key is IC. this code can be conveyed by one
packet when transmitted. the make codes of a handful of special purpose
key, which are known as the extended key, can have 2 to 4 byte. a few of
these key are sow in figure 8. for example, the make code of the upper arrow
on the right is E0 75. multiple packet are need for the transmission. the break
codes of the regular keys consist of F0 followed by the make code of the key.
for example, the break code of A key is F0 1C.
oversampling procedure
the most commonly used sampling rate is 16 time the baud rate, which
means that each serial bit is sampled 16 time. assume that the
communication uses N data bit and M stop bit. the oversampling scheme
work as follows:
1. wait until the incoming signal become '0' the begining of the start bit, and
the start the sampling tick counter.
2. when the counter reaches 7, the incoming signal reach the middle point of
the start bit . clear the counter to 0 and restart.
3. when the counter reach 15, the incoming signal progresses for one bit and
reaches the middle of the first data bit. retrieve its value, shift it into a
register, and restart the counter.
4. repeat step 3 N-1 more time to retrieve the remaining data bits.
5. if the optional parity bit is used, repeat step 3 one more time to optain the
parity bit.
6. repeat step 3 M more tie to obtain the stop bits.
mod-m counter
a mod m counter count from 0 to m-1 and wrap around. a parameterized
mod-m counter is show in listing 4. it has two generics. one is M, which
specifies the limit, m and the other is N, which specifies the number of bits
needed and should be equal to (log2 M).
tick counter.