22.09.2015 Views

of Microprocessors

Musical-Applications-of-Microprocessors-2ed-Chamberlin-H-1987

Musical-Applications-of-Microprocessors-2ed-Chamberlin-H-1987

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ORGAN KEYBOARD INTERFACE 307<br />

with the upper bus is remade the velocity count is reset. Finally, however,<br />

the bouncing stops and the State 1 looparound increments the velocity<br />

counter on each scan cycle. The very first time contact with the lower bus is<br />

seen, a press event is generated using the accumulated velocity count. Thus,<br />

the desired timing from last upper bounce to first lower bounce is implemented.<br />

An exactly analogous sequence occurs when the key is released.<br />

Note that simultaneous contact with both upper and lower buses is physically<br />

impossible and therefore not accounted for in the diagram.<br />

Program Description<br />

A complete, assembled program listing for the keyboard is given in<br />

Fig. 9-9. Looking at RAM memory allocation first, it is seen that nearly half<br />

<strong>of</strong> it is devoted to saving information about the state <strong>of</strong> each key. The low 2<br />

bits <strong>of</strong>each byte are used to hold the state number, while the upper 6 bits are<br />

used as a velocity counter. The entire state byte is 0 if a key is inactive.<br />

Thirty-two more bytes are used to implement an event queue, which allows<br />

up to seven events to be stacked up before overflow. Five bytes are used to<br />

0001 0000<br />

0002 0000<br />

0003 0000<br />

0004 0000<br />

0005 0000<br />

0006 0000<br />

0007 0000<br />

0008 0000<br />

0009 0080<br />

0010 0081<br />

0011 0082<br />

0012 0083<br />

0013 009C<br />

0014 008C<br />

0015 0100<br />

0016 0000<br />

0017 0400<br />

0018 0440<br />

0019 FCOO<br />

0020 0000<br />

0021 0000<br />

0022 0000<br />

0023 0000<br />

0024 0000<br />

0025 0030<br />

0026 003E<br />

0027 003F<br />

0028 005F<br />

0029 0062<br />

0030 0064<br />

0031 0065<br />

0032 0067<br />

0033 0067<br />

0034 0067<br />

0035 0067<br />

PORAM<br />

PAREG<br />

PAOIR<br />

P8REG<br />

P8DIR<br />

TMWRI<br />

TMRD<br />

P1RAM<br />

MKYBU<br />

MKYBL<br />

ROM<br />

MKYBST<br />

OUIP<br />

QUOP<br />

EVQU<br />

TIME<br />

TIMEF<br />

TIMCNT<br />

VCJPPT<br />

MUSIC KEYBOARD CONTROL PROGRAM<br />

THIS EXAMPLE PROGRAM SCANS A 61 NOTE VELOCITY SENSITIVE MUSIC<br />

KEYBOARD AND FORMATS THE SIGNIFICANT EVENTS INTO 4 BYTE GROUPS<br />

FOR USE BY A HOST MICROCOMPUTER SYSTEM.<br />

DEVICE AND MEMORY ADDRESSES<br />

$0000<br />

$0080<br />

$0081<br />

$0082<br />

$0083<br />

$009C<br />

$OoaC<br />

$0100<br />

$0400<br />

$0440<br />

$FCOO<br />

RAM MEMORY ALLOCATION<br />

*= PORAM<br />

*=*+ 61<br />

*=*+ 1<br />

*=*+ 1<br />

*=*+ 32<br />

*=*+ 3<br />

*=*+ 2<br />

*=*+ 1<br />

*=*+ 2<br />

IN ITI ALI ZATI ON<br />

*= ROM<br />

FIRST PAGE 0 RAM LOCATION<br />

6532 I/O PORT A DATA REGISTER<br />

6532 I/O PORT A DIRECTION REGISTER<br />

6532 I/O PORT B DATA REGISTER<br />

6532 I/O PORT B DIRECTION REGISTER<br />

6532 TIMER WRITE, /1, ENABLE TIMER INTERRUPT<br />

6532 TIMER READ, LEAVE INTERRUPT ENABLED<br />

FIRST PAGE 1 RAM LOCATION (IS SAME 128<br />

BYTES AS PORAM<br />

BASE ADDRESS OF MUSIC KEYBOARD UPPER BUS<br />

BASE ADDRESS OF MUSIC KEYBOARD LOWER BUS<br />

FIRST LOCATION IN lK EPROM<br />

SPACE FOR THE CURRENT STATE OF 61 KEYS<br />

EVENT QUEUE INPUT POINTER<br />

EVENT QUEUE OUTPUT POINTER<br />

SPACE TO QUEUE UP TO 7 EVENTS<br />

ELAPSED TIME IN MILLISECONDS SINCE TURNON<br />

FRACTIONAL PART OF ELAPSED TIME<br />

5 COUNTER FOR TIMER INTERRUPTS<br />

INDIRECT POINTER FOR VECTOR JUMP<br />

; START AT BEGINNING OF ROM<br />

Fig. 9-9. Listing <strong>of</strong> keyboard control program

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!