Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay in read_byte may be too long #18

Open
nomis opened this issue Jul 17, 2022 · 0 comments
Open

Delay in read_byte may be too long #18

nomis opened this issue Jul 17, 2022 · 0 comments

Comments

@nomis
Copy link

nomis commented Jul 17, 2022

Running on a LOLIN D1 mini I've had to decrease the delay in read_byte to 16 or 17 swim clock cycles or there's always a timeout on bits 6, 7 or 8.

The decimal "indicate which bit failed" offset isn't very usable because stm8flash reports unknown error codes as hex.

--- src/driver/swim.c
+++ src/driver/swim.c
@@ -181,11 +182,11 @@ static int read_byte() {
   uint32_t parity = 0;
   uint32_t i;
   for (i = 0; i < 9; i++) {
-    sync_ccount(next + 18 * SWIM_CLOCK);
+    sync_ccount(next + 17 * SWIM_CLOCK);
     int bit = read_bit(&next);
     if (bit == SWIM_ERROR_READ_BIT_TIMEOUT) {
       // indicate which bit failed (for debugging)
-      return -i - 20;
+      return -i - 0x20;
     }
     result = result << 1 | !!bit;
     parity ^= result;
@nomis nomis changed the title Delay in read_byte may be too long Delay in read_byte may be too long Jul 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant