<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=Z80%3APorts%3APort01</id>
	<title>Z80:Ports:Port01 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=Z80%3APorts%3APort01"/>
	<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=Z80:Ports:Port01&amp;action=history"/>
	<updated>2026-05-13T12:34:12Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.3</generator>
	<entry>
		<id>http://learn.cemetech.net/index.php?title=Z80:Ports:Port01&amp;diff=329&amp;oldid=prev</id>
		<title>Maintenance script: Initial automated import</title>
		<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=Z80:Ports:Port01&amp;diff=329&amp;oldid=prev"/>
		<updated>2016-02-05T23:56:01Z</updated>

		<summary type="html">&lt;p&gt;Initial automated import&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Basic Info =&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Port Address: 01&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This port reads key presses from the keypad. The keypad is divided into a series of groups. &lt;br /&gt;
&lt;br /&gt;
= Writing to Port =&lt;br /&gt;
&lt;br /&gt;
$FF : Reset the keypad. This unselects all groups and resets the keypad state.&lt;br /&gt;
Anything else : Any 0 bit adds the corresponding group to the list of monitored groups. When a key in a monitored group is pressed, the corresponding key bit reads 0, otherwise it reads 1 (active-low).&lt;br /&gt;
&lt;br /&gt;
= Reading from Port =&lt;br /&gt;
&lt;br /&gt;
Bits are set according whether corresponding keys from selected groups are pressed. Groups are selected through writing to the port. A pressed key reads a 0 bit. An unpressed key reads a 1 bit. The port reads FF after a reset (write FF).&lt;br /&gt;
&lt;br /&gt;
== Key Map: ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
| || &amp;#039;&amp;#039;&amp;#039;Group Bit&amp;#039;&amp;#039;&amp;#039; || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 &lt;br /&gt;
|-&lt;br /&gt;
| || &amp;#039;&amp;#039;&amp;#039;Group Mask&amp;#039;&amp;#039;&amp;#039; || FE || FD || FB || F7 || EF || DF || BF || 7F &lt;br /&gt;
|-&lt;br /&gt;
! Key Bit !! (Mask) &lt;br /&gt;
|-&lt;br /&gt;
! 0|| (FE) || DOWN || ENTER || (-) || . || 0 ||  || GRAPH &lt;br /&gt;
|-&lt;br /&gt;
! 1|| (FD) || LEFT || + || 3 || 2 || 1 || STO || TRACE &lt;br /&gt;
|-&lt;br /&gt;
! 2|| (FB) || RIGHT || - || 6 || 5 || 4 || LN || ZOOM &lt;br /&gt;
|-&lt;br /&gt;
! 3|| (F7) || UP || * || 9 || 8 || 7 || LOG || WIND &lt;br /&gt;
|-&lt;br /&gt;
! 4|| (EF) || || / || ) || ( || , || x^^2^^ || Y= &lt;br /&gt;
|-&lt;br /&gt;
! 5|| (DF) || || ^ || TAN || COS || SIN || x^^-1^^ || 2nd &lt;br /&gt;
|-&lt;br /&gt;
! 6|| (BF) || || CLEAR || VARS || PRGM || APPS || MATH || MODE &lt;br /&gt;
|-&lt;br /&gt;
! 7|| (7F) || || || || STAT || X,T,θ,&amp;#039;&amp;#039;n&amp;#039;&amp;#039; || ALPHA || DEL &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: Group FB Key FE is NEGATE, not to be confused with SUBTRACT.&lt;br /&gt;
Note: Group DF Key FE would be ON, but the ON key is tested elsewhere (a &amp;quot;special case&amp;quot; key - after all, it is the ON key).&lt;br /&gt;
Note: Group EF Key BF (APPS) is called MATRIX on the TI-83.&lt;br /&gt;
&lt;br /&gt;
= Comments =&lt;br /&gt;
TI&amp;#039;s code always resets the keypad before scanning; sometimes, you may get incorrect values if you scan without resetting first.&lt;br /&gt;
&lt;br /&gt;
Traditionally, a delay of a dozen or so clock cycles (6 MHz mode) is used between changing key groups and reading the result. The required delay seems to vary depending on the calculator; some require no delay, others a longer one. The delay is based on real time, not CPU clock cycles; you&amp;#039;ll need to make your delay about 3 times longer in 15 MHz mode. However, as in the example, other people seem to find that resetting before every group change negates the need for a delay; some more experimentation is required.&lt;br /&gt;
&lt;br /&gt;
You should disable interrupts or use a custom interrupt before manually reading this port, because TI&amp;#039;s interrupt scans the keypad. If you leave TI&amp;#039;s interrupt active when manually reading the keypad, sometimes it will fire between when you set and read the port, and you&amp;#039;ll read garbage.&lt;br /&gt;
&lt;br /&gt;
= Example Uses =&lt;br /&gt;
&lt;br /&gt;
    ld a, 0FFh ;Reset the keypad.&lt;br /&gt;
    out (1), a&lt;br /&gt;
    ld a, 0FEh ;Select group 0.&lt;br /&gt;
    out (1), a&lt;br /&gt;
    in a, (1) ;Test for keys.&lt;br /&gt;
    and 2 ;Test for Left Arrow key by making A 0 if left was pressed.&lt;br /&gt;
    call z, LeftArrowPressed ;If 0 then left was pressed.&lt;br /&gt;
    ld a, 0FFh ;Reset the keypad.&lt;br /&gt;
    out (1), a&lt;br /&gt;
&lt;br /&gt;
{{lowercase}}&lt;br /&gt;
[[Category:Z80 Assembly]]&lt;br /&gt;
[[Category:Z80 Heaven]]&lt;br /&gt;
[[Category:Z80 Ports]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>