fix(kernel): allow command-phase byte reception while ATN is asserted #3
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/command-phase-atn-abort"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The IEC listener never decoded the
LISTENcommand and always fell through to "not addressed -> IDLE", so a real C64 transfer was never participated in. The captured logic-analyzer trace showed the same: the bus presence was acknowledged, but no per-byte handshake ever took place.Root cause
wait_clk()aborted byte reception whenever ATN was asserted (low). However, ATN is held low for the entire command phase by design — that is precisely how the talker signals that the byte on the bus is a command.As a result, the first
wait_clk()poll insidereceive_byte()saw ATN asserted and returnedIEC_RX_ATNimmediately, before a single bit was clocked. The state machine then busy-looped, re-enteringreceive_byte()(each call aborting instantly) until ATN was released — at which pointaddressed_listenerwas stillfalse, dropping the bus toIDLE.Fix
The ATN abort is now phase-relative, with
IEC_RX_ATNmeaning "ATN changed, abort":The condition collapses neatly to
iec_atn_asserted() == data_phase, and the phase flag is threaded through to allwait_clk()call sites inreceive_byte().Verification
Bit order and polarity were cross-checked against the real-printer captures and are unchanged: LSB-first, sample-on-CLK-release, released = 1. This reproduces the recorded bytes exactly (
$24->LISTEN 4,$48->H). The command -> data turnaround now works: after the final command byte, the inter-bytewait_clk()observes the ATN release and the state machine proceeds into the addressed data phase.The kernel module was not built or loaded as part of this change; on-hardware validation against a real C64 is expected to follow.
Closes #2
Generated by Clanker