Forum Rule: Always post complete source code & details to reproduce any issue!
Page 24 of 24 FirstFirst ... 14 22 23 24
Results 576 to 579 of 579

Thread: New I2C library for Teensy3

  1. #576
    Senior Member
    Join Date
    Mar 2013
    Location
    Austin TX
    Posts
    386
    Quote Originally Posted by tonton81 View Post
    just out of curiosity of watching the chip registers to see if their intact to make sure i2c bus is operational, does the library have it's own check built in to detect operational bus without writing a request to the device on the bus?
    Internally the library maintains its state through several variables in the i2cStruct (refer to i2c_t3.h file, and look for i2cStruct, then "Current" variables). There are functions to access some of those, but i2cStruct is public, so any setting can be read from it at any time (eg. Wire.i2c->currentRate for example).

    If it needs to determine bus state it will check C1 register (I2C_C1_MST) and S register (I2C_S_BUSY). Refer to the acquireBus_() function to see how it checks those. It does not require talking to Slaves on the bus.

  2. #577
    Senior Member
    Join Date
    Nov 2012
    Location
    Salt Lake City, UT, USA
    Posts
    240
    Quote Originally Posted by tonton81 View Post
    just out of curiosity of watching the chip registers to see if their intact to make sure i2c bus is operational, does the library have it's own check built in to detect operational bus without writing a request to the device on the bus?
    If by seeing if any of the bus lines are stuck, we have added a simple pin-wiggle high and low test to the startup code in our project which depends on I2C for a lot of the system I/O. Then we report SDA or SCL stuck low or high as errors. Not sure if that's what you are asking here.

    If a clock gets "lost" or missed by a slave, it could fail to release the bus, and the library has the ability to send extra clocks to recover from that, if you enable it. I added the ability to see if that recovery has happened, it's in a pull request which you can view if curious about what was added and want to duplicate that.

  3. #578
    Senior Member
    Join Date
    Nov 2012
    Location
    Salt Lake City, UT, USA
    Posts
    240
    Quote Originally Posted by chrisCode View Post
    Hi,
    is there any option to send data to multiple slaves in one DMA-mode session? I mean write buffer with 1st slave address and data, 2nd slave addr and data (3th and so on) and then use sendTransmission() function?
    See @nox771s answer which relates to i2c_t3. But in the bigger world if you have intelligent I2C slaves (microcontrollers) then yes, you can have a multi-master system on I2C or perhaps more correctly, it is a multi-peer system. You can send a message modeled on UDP and all slaves can receive it at the same time. Those that want to pay attention to it can. It's like a broadcast vs sending to one slave. We implemented such a system for a robotic platform and it worked well. The trick is arbitration resolves in the "UDP like" header so there is never a clash of multiple slaves responding to one message. There's nothing preventing this in the I2c spec, though a peer I2C net is unusual.

  4. #579
    Senior Member
    Join Date
    Mar 2013
    Location
    Austin TX
    Posts
    386
    Just FYI - I've uploaded a v9.3 release to the top post and GitHub. It fixes a Slave-mode bug in the ISR for LC/3.5/3.6 devices (STOP bit not properly triggering callback). Try the update if you have any problem running that configuration.

    Edit: Just re-uploaded to merge Paul's Teensy 2.0 patch. First post and GitHub are updated.
    Last edited by nox771; 09-20-2017 at 03:39 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •