adafruit / adafruit/Adafruit_nRF52_Arduino

I2C communication between NRF52832 hangs

Open
#771 2 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
C
Stars
699
Forks
570
PR merge metrics
No merged PRs in 30d

Description

### Operating System

MacOS

### IDE version

Arduino 2.1.0

### Board

Feather 52832

### BSP version

1.4.0

### Sketch

Receiver:

```
#include
#include

void setup()
{
Serial.begin(115200);
while(! Serial) delay(10);
Wire.begin(0x50);
Wire.onReceive(receiveEvent);
}

void loop()
{
delay(100);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
while(1 < Wire.available()) // loop through all but the last
{
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
}
```

Sender:

```
#include

void setup()
{
Wire.begin(); // join i2c bus (address optional for main)
}

byte x = 0;

void loop()
{
Wire.beginTransmission(0x50); // transmit to device #0x50
Wire.write("x is "); // sends five bytes
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting

x++;
delay(500);
}
```

### What happened ?

Two NRF52832 Feather is connected via I2C port. When sender is running without the receiver attached, the sketch is running fine. But when the receiver is attached, the sender hangs on endTramission.

### How to reproduce ?

Connect Sender SCL, SDA to another NRF52832 SCL and SDA port. Connect a 2.2k Pull up resistor between SCL and VCC, SDA and VCC. Once receiver is attached, the sender will hang.

### Debug Log

_No response_

### Screenshots

I2C bus scope capture:
![DS1Z_QuickPrint1](https://github.com/adafruit/Adafruit_nRF52_Arduino/assets/11619780/c70f00be-596f-4066-842f-3bcce21d19f0)

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue provides sender and receiver sketches; begin by running them on two Feather 52832 boards with the stated I2C wiring and observe the sender at Wire.endTransmission(). Trace the I2C/Wire handling around that call and the receiver's Wire.onReceive(receiveEvent); done means repeated transfers complete instead of hanging when the receiver is attached.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.