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

ESP8266 controller will crash the target firmware if addresses >=0x40 are used on the bus #1

Closed
ftjuh opened this issue Mar 20, 2023 · 0 comments

Comments

@ftjuh
Copy link
Owner

ftjuh commented Mar 20, 2023

ESP8266 as controller uses a very tight timing after a start condition. Analysis with a logic analyzer shows that the ESP8266 will pull SDA up very soon after pulling SCL low. Addresses >= 0x40 will result in a '1' bit sent immediately after that.

Logic Analyzer output from Pulseview (remove ".zip" from file extension): 0x40 24Mhz 20k samples.sr.zip

The original code will erroneously interpret this as a stop condition because it does not buffer the state of SDA between detecting a pin change and interpreting this change as a stop condition. Also, it ignores SCL in doing so.

        // Wait until end of start condition or begin of stop condition 
        while ((PINB & 128) && !(PINB & 32));

        // Break when a stop condition has been received while waiting
        if (PINB & 32) {
          break;
        }

After the false detection of a stop detection the above break; command will cause an exit from the main loop, putting the device in an undefined, non reactive state.

@ftjuh ftjuh closed this as completed in 4a74c94 Mar 20, 2023
ftjuh added a commit that referenced this issue Mar 20, 2023
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