Hi all,
the topic of "how to send a character to the parallel printer" may seem simple, but in practice it is not so simple (at least in my personal experience, based on interfacing EPSON LX350 with RC2014 via Steven Cousins SC103 PIO board).
First of all, let's see the standard "IEEE Standard Signaling Method for a Bidirectional Parallel Peripheral Interface for Personal Computers" (IEEE 1284 - 2000):
<begin quote>
The Compatibility Mode follows pre-existing industry conventions with eight parallel bits, (Data 1–Data 8) qualified by a low-going pulse on HostClk(nStrobe). The peripheral responds by setting PtrBusy(Busy) high to hold off the next byte until the current one has been removed from the input latch. When ready for the next byte, the peripheral pulses PtrClk(nAck) low, then sets PtrBusy(Busy) low. Timing requirements on peripheral Busy ensure that compliant peripherals will interoperate with existing hosts that monitor Busy but not nAck. After receiving Busy low from the peripheral, hosts shall not set nStrobe low until Tready. The peripheral can reactivate Busy asynchronously due to some condition other than the reception of a data byte. Due to this race condition, the host may at that instant be asserting nStrobe low to send the next data byte. The peripheral shall accept at least one byte from the host after entering a Busy state in this situation. Hosts shall provide Tsetup from D1...D8 and nAutoFd stable to the falling edge of nStrobe.
<end quote>
Of course, the standard specifies also the timings (Tstrobe,Tready,...).
My lesson from the standard was to use only Busy (ignoring Ack) :
for each byte
wait not busy
send byte
wait > 0.75u (as the standard said, but for me only 1.5u worked well)
strobe low
wait > 0.75u (as the standard said, but for me only 1.5u worked well)
strobe high
end
I maintain the data bits stable after strobe high >= 5u, before sending the next char.
I tried also delay loops, but failed.
All other wait intervals (different from 1.5u) resulted in duplicate/missing chars.
The 1.5u was obtained with: NOP, NOP, LD A,R
Between series of chars (<256) sent to the printer, I inserted waiting intervals (on interrupts, using RTM/Z80 timers), in order to be "compatible" with the EPSON LX350 documented printing speed ( 350 chars/second ).
Today I fixed a bug related to the CTC interrupts ( when they occurred "inside" a print command, this resulted in skipped chars at print; now I disable the interrupts until the print command is finished, enabling the interrupts after completing the print command).
The current status: I can now print from a RTM/Z80 task several pages on EPSON, while running other tasks. No more missing chars, only some (few) duplicate chars/page. Still I must investigate these duplicate chars...
regards,
Ladislau