JDat / AtTiny-I2C-master-slave-USI

I2C Master and Slave library using USI Hardware
MIT License
15 stars 9 forks source link

USI I2C Slave @ 8MHz talking to Arduino Wire Library - Protocol Error #1

Open jmount1992 opened 6 years ago

jmount1992 commented 6 years ago

Thanks for the USI I2C library, great help. However, I found when in USI I2C Slave mode that if your Microcontroller is running at 8MHz or lower you will need to reduce the Arduino's Wire Library default (100kHz) I2C SCL frequency. Else the timing in the ACK section can be a bit dicey.

To change the Arduino's Wire Library default I2C SCL frequency you need to call Wire.setClock() where SCL_FREQ is anywhere between 31000L to 400000L (31kHz to 400kHz). See begin section here .

This was an extremely annoying bug to hunt down.

Hope this makes sense and helps others.

JDat commented 6 years ago

Thank you for report. There are few problems with this. Some are global, some are local. I incorrectly forked this git. So, I need to fix and fork correctly. I tested this with AtTiny85. I didn't use arduino at all. Only pure C/C++. There was problems when tiny85 is working from 4 MHz, but 8 MHz worked fine with 100 kHz I2C clock. Seems that problem is with code in Interrupt. Interrupt response is too slow.

Because I am not planning to build any project with this library in near future, I will not fix this problem. So, try to contact with library author.