Giter Club home page Giter Club logo

Comments (5)

stevemarple avatar stevemarple commented on June 19, 2024

At the top of SoftWire.cpp this comment explains a potential problem with interrupts:

// If possible disable interrupts whilst switching pin direction. Sadly
// there is no generic Arduino function to read the current interrupt
// status, only to enable and disable interrupts.  As a result the
// protection against spurious signals on the I2C bus is only available
// for AVR architectures where ATOMIC_BLOCK is defined.

This thread suggests there may be an atomic block implementation for the STM32 that could be used.
However I don't know that interrupts are the cause - what happens if you disable interrupts before read() and enable them afterwards?

from softwire.

pacman1945 avatar pacman1945 commented on June 19, 2024

I've tried disable interrupts in llRead(), but the problem persisted. I've tested another software I2C library, SWire link. It works fine with stm32duino and didn't disable interrupts. Thus, I believe the problem with SoftWire isn't related to interrupts.

from softwire.

stevemarple avatar stevemarple commented on June 19, 2024

Did you allocate buffers and pass them into SoftWire using the setTxBuffer() and setRxBuffer() functions? A newly-added example, ReadDS1307 demonstrates this.

from softwire.

LucasFeliciano21 avatar LucasFeliciano21 commented on June 19, 2024

Hey @stevemarple, I'm also testing your library and I can get it to work for the stm32duino witch is this one Arduino Core Stm32, and not the one that you've published. I'm not sure if @pacman1945 is looking for the SoftWire for the core that you mentioned because it's native and works pretty well.

But returning to the question, I've tested with the code for detecting devices and it detects my device, the problem is, there is no response from the devices when I actually do a transfer to the device, the data coming out is always 0, when I change the library to this one SoftWire from Arduino STM32.

Do you have any idea what that might be?

from softwire.

iLoveAndyBaker avatar iLoveAndyBaker commented on June 19, 2024

I was just having terrible problems with this library on STM32 (STM32F103C8T6), needing a logic analyzer to ferret out the problem, and also a code problem, which was working fine when using the wire library.

The job was a reverse engineering on some Alibaba Ali Express mystery boards, a port from a SAMD / Arduino Zero to STM, and the schematic was botched, requiring software I2C. Doing this work in Platform.io, with soft input pullups enabled. The chip I'm developing on seems to be a legit STM32F103C8T6, I can confirm the same behavior on clearly counterfeit chips as well. Literally spent 5 weeks banging my head against this problem. I could write registers, but couldn't read them.

This may not be the same problem exactly, but the chip and symptoms are.

This is the change that made it live.

iTwoSea.beginTransmission(DevAddr);
iTwoSea.write(RegAddr);
iTwoSea.endTransmission();
//iTwoSea.endTransmission(false); // Original code - This line screws up soft I2C
iTwoSea.requestFrom(DevAddr, (uint8_t)4);

The SDA line wasn't dropping to switch to receive. Getting rid of (false) fixed it.

image
Not what I asked for...

image
For the win!

from softwire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.