arduino / arduino/ArduinoCore-samd

SERCOM I2C not working on pins PA08, PA09

Open
#383 15 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
502
Forks
740
PR merge metrics
No merged PRs in 30d

Description

Hardware platform: Sparkfun SAMD21 Mini Breakout + BME280 sensor + VL53L0X sensor
Software platform: Arduino 1.8.3, Arduino SAMD Boards 1.6.20, Sparkfun SAMD21 boards 1.5.3, Windows 10 Pro 1803

Aim:
- setup an additional hardware I2C bus on pins PA08, PA09 in addition to the default one on pins PA22, PA23.

Result:
- different units of the same sensor work on default I2C (SERCOM3) as well as on PA16, PA17 (SERCOM1), but fails to work on pins PA08, PA09 (both SERCOM0 and SERCOM2_ALT)
- We tested different sensor (VL53L0X), different BME280 libraries (Adafruit and Sparkfun) and different Sparkfun boards but the issue persists.

Steps to reproduce:
1. Connect sensor SDA, SCL to pin 4, 3 of said board (corresponding to pin PA08, PA09 of SAMD21)
2. Upload this code:
```
#include
#include "wiring_private.h" // pinPeripheral() function
#include

TwoWire myWire(&sercom0, 4, 3);

BME280 bme1; // I2C

void setup() {
// put your setup code here, to run once:
SerialUSB.begin(115200);
while (!SerialUSB) {
; // wait for serial port to connect
}

SerialUSB.println("SAMD21 Test Initialization");
SerialUSB.println();

SerialUSB.println("Initializing I2C on pin 4, 3");


myWire.begin();
pinPeripheral(4, PIO_SERCOM);
pinPeripheral(3, PIO_SERCOM);

SerialUSB.println("Inizialized, looking for sensor");
if(bme1.beginI2C(myWire) == false) {
SerialUSB.println("Sensor NOT found!");
} else {
SerialUSB.println("Sensor found");
}
}

void loop() {
// put your main code here, to run repeatedly:
SerialUSB.print("Sensor 2 temp: ");
SerialUSB.println(bme1.readTempC(), 2);
delay(5000);
}
```

3. Sketch is stuck at "Initializing I2C on pins 4,3"
4. Now connect sensor SDA, SCL to pin 11,13 of the MCU
5. Upload the code with these changes:
```
TwoWire myWire(&sercom1, 11, 13);
pinPeripheral(11, PIO_SERCOM);
pinPeripheral(13, PIO_SERCOM);
```
6. Sketch is running normally and outputting sensor temperature

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with Wire.h, wiring_private.h, TwoWire, and the SERCOM pin configuration used by the sketch. Reproduce the difference between pins 4/3 (PA08/PA09) and pins 11/13 (PA16/PA17), then trace why SERCOM0 or SERCOM2_ALT does not initialize on PA08/PA09. Done means the supplied sketch can initialize the sensor and read temperature on PA08/PA09 as it does on PA16/PA17.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.