From f32de52b4698b1bb40be97dd8a35c8ba7cfdbc96 Mon Sep 17 00:00:00 2001 From: Jean-Michel Picod Date: Fri, 9 Dec 2022 13:17:19 +0100 Subject: [PATCH] Wait a bit longer for the smartcard. For the max 256-byte frame, SIM wasn't ready early enough, corrupting the reception buffer with 5 spurious bytes. Empirically, 109 clock cycles is the minimum value that worked. Adding 1 clock cycle as a safety buffer. --- armsrc/i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/armsrc/i2c.c b/armsrc/i2c.c index b9b536c24..491e12a04 100644 --- a/armsrc/i2c.c +++ b/armsrc/i2c.c @@ -235,9 +235,9 @@ static bool I2C_WaitForSim(void) { // 8051 speaks with smart card. // 1000*50*3.07 = 153.5ms - // 1000*90*3.07 = 276.3ms + // 1000*110*3.07 = 337.7ms // 1byte transfer == 1ms with max frame being 256bytes - return WaitSCL_H_delay(1000 * 90); + return WaitSCL_H_delay(1000 * 110); } // send i2c STOP