Specifications
5-8 MIDI Port I/O Programming
Reset
The command byte 0FFh is used to reset the MPU-401 interface. After resetting the
interface, a Command Acknowledge byte, 0FEh, should be read back from the Data
port.
This mechanism can also be used to detect the existence of the MPU-401 interface.
After an interface reset, the data read in from the Data port should be verified to be
0FEh. If this fails, either the MPU-401 is not installed, or it does not exist at that I/O
address.
Example code:
mov dx,wMpuBaseAddx ;MPU-401 base I/O address
inc dx ;Status port
Busy:
in al,dx ;Read status port
test al,40h ;Ready for output?
jnz Busy ;No
mov al,0FFh ;Output "Reset" command
out dx,al ; via Command port
sub cx,cx ;Maximum of 65536 tries
Empty:
in al,dx ;Read status port
test al,80h ;Input data ready?
jnz NextLoop ;No
dec dx ;Data port
in al,dx ;Read data
cmp al,0FEh ;Successfully reset?
je ResetOK ;SUCCESS!
inc dx ;Status port
NextLoop:
loop Empty ;Try again
;***
;*** Failed to reset: MPU-401 not detected