I2C on ATtiny 841 #833
Replies: 5 comments 4 replies
-
Do I see series resistors in your schematic I2C lines instead of pullup resistors? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I've retested this, and made sure the resistors are 4.7k and are pulling up. the and can confirm that this configuration is not working on the 841, but is working on the 85. Since I'm just moving the green and blue jumper wires to the appropriate spot between the two chips I'm fairly confident that theres something outside the wiring and usage off pullups thats preventing me from reading from the sensor. |
Beta Was this translation helpful? Give feedback.
-
Okay folks, its a rainy day. So I broke out my oscilloscope. The last known commit when I2C master functionality works correctly on the Tiny841 platform is when SoftI2CMaster.h is at the following revision:
One or more changes thereafter break functionality. Further, maybe I misunderstood the exchange with Spence earlier, but I now believe that the pins in hardware/ATTinyCore/avr/variants/tinyx41_cw/pins_arduino.h as they currently stand are not correct (they do not correspond to the wiring diagram here: https://github.com/SpenceKonde/ATTinyCore/blob/v2.0.0-devThis-is-the-head-submit-PRs-against-this/avr/extras/ATtiny_x41.md). In my opinion, they should be presented as such:
The way I narrowed everything down is by writing a simple I2C peripheral device program on the Tiny85. I then used another '85 to control the peripheral device. This controlling code was placed on an Tiny841 as well. The 'scope probes were placed on the diagrammed SDA/SCL lines. Channel 1 is always orange, and corresponds to what should be the SCL line, Channel 2, in blue, is what should be the SDA line. First lets look at the waveforms for the tiny85 controller: Seems to look pretty nice- clock seems fairly steady. Here's what things look like on the tiny841 master, currently: Seems odd- the clock pin on channel 2, and the data pin is on channel one. Simply reversing the lines didn't get the peripheral device to respond. So I did some differential diffing and moved the codeline for SoftI2CMaster.h only to commit 3853428. Heres the output on the scope: Seems to look much better- we have a steady clock, but again on channel 2, which is connected to what is diagrammed as SDA on ATTinyCore doc (see above link) Reversing the code in Seems much more in line with the Tiny85 waveform as seen in first diagram. The clock is on channel 1 (orange) and we are getting data now on channel 2 (blue). Finally, hooking it up in the logical way (as one would expect via the pinout diagram) to the Tiny85 peripheral device, and its been smooth sailing (for this small contrived case anyway). Hope this helps to make things better, happy to share the code and my wiring testbed that i'm using to help sort this out. Don't think its super necessary since the scope output is way easier to comprehend at a glance, but if it helps I'm happy to post. |
Beta Was this translation helpful? Give feedback.
-
Wow, I looked at that quoted section of code like a dozen times before I saw that they were backwards there. That definitely makes sense. I don't recall what any of the changes to softI2C were aimed at though, will have to dig into that. Of course that requires I also find a programmer and make it work. I don;'t know where any of my classic AVR programmers are as i'm in the middle of a chain of multiple relocations. |
Beta Was this translation helpful? Give feedback.
-
Hi! I'm wondering if anyone's been able to get software i2c master functionality working recently on the latest codeline? I'm having trouble with using the 841 to control a device (A5600), however the same code is functioning fine with the Attiny85 (think slow mode was enabled when I tested). I've tried all sorts of pull ups on the 841 CLK/SDA lines (0 (meaning directly wired), 2k, 4.7k and 10k) to no avail. wire.endTransmission() is always returning an error (2: received NACK on transmit of address.) I understand that error reporting is unreliable, but also I can't get any data off the device. I've also tried enabling slow mode. Nothing seems to work, and no matter the wiring, I'm always getting error code 2.
Parts: https://www.amazon.com/Magnetic-Encoder-Induction-Measurement-Precision/dp/B094F8H591
Wiring:
A5600 Library + Main sketch: https://github.com/RobTillaart/AS5600/blob/master/examples/AS5600_position/AS5600_position.ino
In my investigation I did find some interesting pieces that I think is a bug. Here is relevant sections and source code locations:
The modern CW pin mapping:
Versus the legacy ccw pin mapping:
This doesn't seem right, as they both can't be the same if the pin ordering is changed between clockwise and counter clockwise- or maybe I just don't know enough about how the pin indexing works :)
I'm also seeing the following warnings when compiling:
Beta Was this translation helpful? Give feedback.
All reactions