Skip to content

UnConfigured I2C Slave ISR Causing Reboot #6852

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stickbreaker
Copy link
Contributor

@stickbreaker stickbreaker commented Oct 24, 2017

In a MultiMaster I2C environment, The Default value of 0xFE in the TWAR cause the Arduino to respond as an I2C Slave device at address 0x7f. If the Wire.h library was not configured as a I2C Slave, Wire.begin(slaveID); the Callbacks for twi_onSlaveTransmit() and twi_onSlaveReceive() are never initialized.
But, they are called during servicing the TWI ISR. This causes a reboot of the Arduino by jumping to an uninitialized function address (0).
So, this fix initializes them to the Default Wire.h handler which will respond correctly even during Master Mode operations.

A MASTER MODE only Arduino will respond to all Slave Calls that match TWAR, Unless the TWEA bit is disabled outside of Master Transactions. If this response is not acceptable, the TWEA bit must be cleared outside of MASTER MODE transaction. TWEA must be enabled if SLAVE MODE transaction are required.

Chuck.

In a MultiMaster I2C environment, The Default value of 0xFE in the TWAR cause the Arduino to respond as an I2C Slave device at address 0x7f.  If the Wire.h library was not configured as a I2C Slave, `Wire.begin(slaveID);` the Callbacks for `twi_onSlaveTransmit()` and `twi_onSlaveReceive()` are never initialized. 
But, they are called during servicing the TWI ISR.  This causes a reboot of the Arduino by jumping to an uninitialized function address (0).
So, this fix initializes them to the Default Wire.h handler which will respond correctly even during Master Mode operations.
A MASTER MODE only Arduino will respond to all Slave Calls that match TWAR, Unless the TWEA bit is disabled outside of Master Transactions.
Chuck.
It also initialized the TWAR to the General Call ID (0x0) and Disables General Call responses.

Chuck.
@facchinm facchinm added the Library: Wire The Wire Arduino library label Oct 30, 2017
@facchinm facchinm requested a review from cmaglie October 30, 2017 15:05
@facchinm facchinm added the Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) label Nov 13, 2017
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) Library: Wire The Wire Arduino library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants