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

I2C slave does not work above MiniCore v1.0.4 #122

Closed
evansgl opened this issue Dec 19, 2019 · 18 comments
Closed

I2C slave does not work above MiniCore v1.0.4 #122

evansgl opened this issue Dec 19, 2019 · 18 comments

Comments

@evansgl
Copy link

evansgl commented Dec 19, 2019

Seems that all versions of MiniCore v2.x.x are affected by the same issue.
I have an atmega328 as an I2C slave and it does not work properly.
It does not report something in the I2C channel.
If I use the stock and latest arduino hardware pack the I2C slave works. It also works fine with any 1.x.x version of Minicore.

@MCUdude
Copy link
Owner

MCUdude commented Jan 3, 2020

What IDE version are you using? From v2.0.0 and later MiniCore hosts its own version of Wire, while v1.0.4 uses the version that ships with the IDE.

Does it work in your current IDE when using the Arduino UNO as target?

@evansgl
Copy link
Author

evansgl commented Jan 5, 2020 via email

@MCUdude
Copy link
Owner

MCUdude commented Jan 5, 2020

Thanks! I compared the two versions, and there were done some changes to Wire.cpp in 2017 (to fix slave functionality) that I didn't catch. I'll fix it soon! Would you test it for me after I've pushed a fix? 🙂

MCUdude added a commit that referenced this issue Jan 5, 2020
@MCUdude
Copy link
Owner

MCUdude commented Jan 5, 2020

@evansgl I've now pushed a fix. Could you test it with your hardware? You'll have to do a manual installation of MiniCore to get the latest fix.

@evansgl
Copy link
Author

evansgl commented Jan 5, 2020 via email

@MCUdude
Copy link
Owner

MCUdude commented Jan 10, 2020

Did you get the chance to test this? 🙂

@evansgl
Copy link
Author

evansgl commented Jan 11, 2020 via email

@MCUdude
Copy link
Owner

MCUdude commented Jan 11, 2020

That's strange. Did you only copy the Wire.h and Wire.cpp? You also need the two files (twi.h and twi.c) located in the utility folder.

@evansgl
Copy link
Author

evansgl commented Jan 11, 2020 via email

@MCUdude
Copy link
Owner

MCUdude commented Jan 11, 2020

OK. I will try it myself on my own hardware to see if I can figure it out

@MCUdude
Copy link
Owner

MCUdude commented Jan 15, 2020

I did test the master/slave functionality using this code:

https://www.arduino.cc/en/Tutorial/MasterWriter

I used a 328P as a slave. It works just fine with the fix I applied.

@mhmayyan
Copy link

mhmayyan commented Feb 1, 2020

I am using Atmega328PB, MiniCore 2.0.3, Arduino IED 1.8.10.
A slave sender detects a request from a master reader but does not respond. It does not send the bytes (Wire.write()). I am testing the examples "master_reader" and "slave_sender". I used a digital analyzer to see the SDA, SCL lines. I can only see the request from the master but there is no response from the slave.

The two ends are Atmega328PB.

It worked when I replaced the Wire directory from libraries in MiniCore by the Wire folder from standard Arduino AVR core 1.8.2 libraries.

I appreciate your huge efforts. Thank you very much.

@MCUdude
Copy link
Owner

MCUdude commented Feb 1, 2020

@mhmayyan can you retry your test but with a manual install of MiniCore instead? I did push a fix for this that solved this issue for me at least.

@mhmayyan
Copy link

mhmayyan commented Feb 1, 2020

I deleted all the contents of the folder "..\MiniCore\hardware\avr\2.0.3". Then I downloaded the zip file of the repository and extracted the contents of "MiniCore-master.zip\MiniCore-master\avr" into "..\MiniCore\hardware\avr\2.0.3".

The problem is now back. The slave sender does not respond to the master reader but it like before still detects the request from the master reader.

Again, when I replaced the Wire folder in libraries by the one from Arduino AVR it worked.

@MCUdude
Copy link
Owner

MCUdude commented Feb 1, 2020

That's really strange. It works for me!

Can you turn on the compiler output, and have a look at what SPI.cpp file is being compiled, open this and check if this fix are applied to the file?

MCUdude added a commit that referenced this issue Feb 1, 2020
@MCUdude
Copy link
Owner

MCUdude commented Feb 1, 2020

I compared the source files from IDE 1.8.10 with the files from MiniCore, and there was some code lines in the MiniCore version that shouldn't have been there. These have been removed now.

@mhmayyan
Copy link

mhmayyan commented Feb 2, 2020

Now it works.

Thank you very much.

@MCUdude
Copy link
Owner

MCUdude commented Feb 2, 2020

Thanks for testing! Now the library is identical to the official one too. I wil apply this fix to my other Arduino cores as well.

@MCUdude MCUdude closed this as completed Feb 2, 2020
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

3 participants