Walt for Acknowledge
Once the byte has been sent, wait for an acknowledge from the target device by monitoring bit 5 of the GPIP (General Purpose Interrupt Port of the MC68901). Bit 5 is cleared when the target device is ready for the next byte. This operation should also timeout in case a response is not obtained from the target device. See the programming example above for an example of how to do this.
The following programming example combines a required 20 microsecond delay (between command bytes) with the 3 second timeout delay. This loop can be inserted in the "Write the Command Byte to the DMA Port" programming example above to obtain a complete command byte write sequence. The timeout may not be enough for some peripherals (eg. a tape drive, or CD ROM).
Example:
equ SfffffaOl equ $4ba moveq.l #2, dl add.l hz200, dl address of general purpose register system 200Hz timer
approximately 5 millisecond delay timing constant equivalent to 200 hz del20mic: cmp.l hz200, dl bge del20mic are we done looping?
loop until 20 microsecond delay done moveq.l «600, dl add.l hz200, dl start 3 second timeout on Acknowledge
NOTE: The del20mic timing loop is not required for all peripherals.
del3sec: btst.b #5, gpip beg exit test to see if target has acknowledged byte command byte acknowledged loop done?
branch not done otherwise error!
cmp.l hz200, dl bge del3sec moveq.l #-1, dl exit: rts timeout: set error flag in dl and exit
Post a comment