From e9b4c8c22ec7ed843d120131e2f68164ed424eb4 Mon Sep 17 00:00:00 2001 From: janko-jj <165717176+janko-jj@users.noreply.github.com> Date: Tue, 16 Jun 2026 02:51:43 +0200 Subject: [PATCH 1/2] add fast UART Rx FIFO clean --- src/uart.asm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/uart.asm b/src/uart.asm index 4a0a78b..ece469d 100644 --- a/src/uart.asm +++ b/src/uart.asm @@ -48,7 +48,15 @@ SMC_skip_baud_init rla ; Now in Bit 0 or %10000000 ; Set MSB to req. write to upper 7 bits out (c), a - ret + ; stale data taken out from FIFO at max speed +.staleFIFOclean + ld bc, UART_GetStatus + in a, (c) + rra + ret nc + ld bc, UART_RxD + in a, (c) + jr .staleFIFOclean .baudTable: DEFW 243,248,256,260,269,278,286,234 ; 115K @@ -106,7 +114,6 @@ write: IFDEF TESTING call debug ENDIF - ld bc, UART_GetStatus .wait in a, (c) From efb586e2e442e8addc5afdfc77e32d7f0e267485 Mon Sep 17 00:00:00 2001 From: janko-jj <165717176+janko-jj@users.noreply.github.com> Date: Tue, 16 Jun 2026 03:21:24 +0200 Subject: [PATCH 2/2] Removing WaitRaster, adjusting the ESPTimout constant calculation With the WaitRaster and the big constant the timeout became infinity in practice. Therefore after the constant calculation is corrected the WaitRaster is removed. The timeout is set to 60 seconds at 28MHz --- src/constants.inc.asm | 4 +++- src/esp-timeout.asm | 24 +++--------------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/constants.inc.asm b/src/constants.inc.asm index 8369b9c..5ecf40d 100644 --- a/src/constants.inc.asm +++ b/src/constants.inc.asm @@ -22,7 +22,9 @@ CPUSpeed equ $07 VARS EQU $5c4b ; addr of variables area NEXT_ONE_r3 EQU $19b8 ; find next variable -ESPTimeout EQU 65535*4;65535 ; Use 10000 for 3.5MHz, but 28NHz needs to be 65535 +ESPTimeoutInSeconds EQU 60 ; Seconds, use this one to adjust timeout + ; ESPTimeoutI is an 64-bit const which fits CheckESPTimeout +ESPTimeoutI EQU 65535 + ((22*ESPTimeoutInSeconds/10)<<16) ; formula for 28MHz BORDCR EQU 23624 diff --git a/src/esp-timeout.asm b/src/esp-timeout.asm index 6692cc7..a50a8ef 100644 --- a/src/esp-timeout.asm +++ b/src/esp-timeout.asm @@ -1,9 +1,9 @@ InitESPTimeout: MODULE InitESPTimeout push hl - ld hl, ESPTimeout mod 65536 ; Timeout is a 32-bit value, so save the two LSBs first, + ld hl, ESPTimeoutI mod 65536 ; Timeout is a 32-bit value, so save the two LSBs first, ld (CheckESPTimeout.Value), hl - ld hl, ESPTimeout / 65536 ; then the two MSBs. + ld hl, ESPTimeoutI / 65536 ; then the two MSBs. ld (CheckESPTimeout.Value2), hl pop hl ret @@ -18,7 +18,6 @@ Value EQU $+1 ld hl, SMC dec hl ld (Value), hl - call WaitRaster ld a, h or l jr z, Rollover @@ -36,26 +35,9 @@ Value2 EQU $+1 or l jr z, Failure ; If we hit here, 32 bit value is $00000000 dec hl - call WaitRaster ld (Value2), hl - ld hl, ESPTimeout mod 65536 + ld hl, ESPTimeoutI mod 65536 ld (Value), hl jr Success -// https://github.com/remy/next-http/issues/7 -WaitRaster: - push bc - push af -.waitloop: - ld bc, $243b - ld a, $1f ; only really care about lsb - out (c), a - inc b - in a, (c) - cp 192 - jr nz, .waitloop - pop af - pop bc - ret - ENDMODULE