-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Stop bit(ACK) Error on sending command
ERR:17
means error occurs after stop bit.
Debug output from the converter when plugin and capslock key is pressed, tested with firmware beased on commit 19853b4 probably.
Waiting for new device:..............
Listening:
ERR:F0 ISR:FFE0
PRT:23 ISR:0000 [CHG] I65401 wFF A868
ERR:17 ISR:6A90
PRT:11 ISR:0000 X1370 rAA W1813 wF2 R2315
ID:FFFF(1)
ERR:17 ISR:6A90 S2316 L2316 r58 rF0 r58
This was reported by email at 2020-11-14.
ISR:6A90
means 0xAA which received from the keyboard. The keyboard seems to reset when sending command fails with ERR:17
?
It seems that Zenith Z-150 is not compatible to AT protocol and it lacks 11th clock when host sends a command.
https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#zenith-z-150-beige
Fix 1
The converter doesn't wait for 11th clock after it recoginized protocol for Z-150 AT.
This should work but won't before the protocol recognition.
Commit 7e268c8
diff --git a/tmk_core/protocol/ibmpc.c b/tmk_core/protocol/ibmpc.c
index 0e94e301..0f093f80 100644
--- a/tmk_core/protocol/ibmpc.c
+++ b/tmk_core/protocol/ibmpc.c
@@ -136,6 +136,7 @@ int16_t ibmpc_host_send(uint8_t data)
wait_us(15);
data_hi();
WAIT(clock_hi, 50, 6);
+ // Zenith Z-150 AT doesn't have 11th clock for ACK.
+ if (ibmpc_protocol == IBMPC_PROTOCOL_AT_Z150) { goto RECV; }
WAIT(clock_lo, 50, 7);
@@ -156,6 +157,11 @@ RECV:
return ibmpc_host_recv_response();
ERROR:
ibmpc_error |= IBMPC_ERR_SEND;
+
+ // This error can happen before protocol recognition of Zenith Z-150 AT.
+ // https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#zenith-z-150-beige
+ if (!ibmpc_protocol && ibmpc_error == 7) { goto RECV; }
+
idle();
IBMPC_INT_ON();
return -1;
Fix 2
This works as well, instead of Fix 1. Fix 1 seems to be preferable though.
When ERR:17
happens at startup converter tries to receive response for Z-150 AT.
diff --git a/converter/ibmpc_usb/ibmpc_usb.c b/converter/ibmpc_usb/ibmpc_usb.c
index 6d22ad73..ef35e5a5 100644
--- a/converter/ibmpc_usb/ibmpc_usb.c
+++ b/converter/ibmpc_usb/ibmpc_usb.c
@@ -201,7 +201,12 @@ uint8_t matrix_scan(void)
if (0xFA == ibmpc_host_send(0xFF)) {
state = WAIT_AA;
} else {
- state = XT_RESET;
+ // With Zenith Z-150 AT stop bit error occurs before recognized
+ if (0x17 == ibmpc_error && 0xFA == ibmpc_host_recv_response()) {
+ state = WAIT_AA;
+ } else {
+ state = XT_RESET;
+ }
}
xprintf("A%u ", timer_read());
break;
Fix signal check for ACK
2021-05-25
Original PC/AT Keyboard Controller doesn't check clock pulse for ACK, probably Z-150 AT works with the original controller without problem. Both fixes above are not needed in the end.
With seeing ROM dump list of the keyboard controller it checks only DATA line with longer timeout on ACK. (0277, 027B)
http://halicery.com/8042/8042_1503033.TXT
Before fix:
tmk_keyboard/tmk_core/protocol/ibmpc.c
Lines 135 to 146 in 343c32a
/* Stop bit */ | |
wait_us(15); | |
data_hi(); | |
WAIT(clock_hi, 50, 6); | |
WAIT(clock_lo, 50, 7); | |
/* Ack */ | |
WAIT(data_lo, 50, 8); | |
/* wait for idle state */ | |
WAIT(clock_hi, 50, 9); | |
WAIT(data_hi, 50, 10); |
With fix:
/* Stop bit */
wait_us(15);
data_hi();
/* Ack */
WAIT(data_lo, 300, 6);
WAIT(data_hi, 300, 7);
// this is optional?
WAIT(clock_hi, 300, 8);
Z-150 AT seems to be slow for clock pulse for ACK, or no pluse at all.(Not confirmed)
Z-150 AT:
__ _ 1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7 _ 8 _ 9 _ A ________
CLK \____/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ XXXXX
______ ___ ___ ___ ___ ___ ___ ___ ___ ______ ____
DAT \___/___X___X___X___X___X___X___X___X___/ \___/
I S 0 1 2 3 4 5 6 7 P S ACK
Fixed repo at: 0a1dcac
2021-06-03