arduino / ArduinoCore-samd

Arduino Core for SAMD21 CPU
GNU Lesser General Public License v2.1
465 stars 715 forks source link

Alternate SERCOM I2C Not Working On Pins PA08 and PA09 (4 and 3) #711

Open DeltaAerospace opened 9 months ago

DeltaAerospace commented 9 months ago

I2C is not working using PA08 and PA09 on the ATSAMD21G18A-AU with an Arduino Zero bootloader on a custom PCB. -Tried Modified I2C Scanner -Normal I2C on PA22 and PA23 still work

wltue commented 2 months ago

Works for me. Problems could be init in the library I had a lot of issues with external libraries if != Wire'0', If the library tries to init the Wire remove the line (.begin) and add it manually in your setup.

Try manualy, this works:

`#include

include "wiring_private.h" // for pinPeripheral() function

include

TwoWire Wire1(&sercom2, // &PERIPH_WIRE 4, // PIN_WIRE_SDA 3); // PIN_WIRE_SCL

void setup() {

// Init Wire1 Wire1.begin(); Wire1.setClock(100000); pinPeripheral(4, PIO_SERCOM_ALT); pinPeripheral(3, PIO_SERCOM_ALT);

Serial1.begin(115200); }

void loop() {

Wire1.beginTransmission(0x40);

Wire1.write(0b101010); // Sends value byte Wire1.endTransmission(); // Stop transmitting

delay(500); } ` (set the parameters according to your i2c chip connected)

DeltaAerospace commented 2 months ago

Since I posted this, I’ve got it working. Thanks for the help.

On Mon, May 20, 2024 at 9:06 PM tse @.***> wrote:

Works for me. Problems could be init in the library I had a lot of issues with external libraries if != Wire'0', If the library tries to init the Wire remove the line (.begin) and add it manually in your setup.

Try manualy, this works:

`#include

include "wiring_private.h" // for pinPeripheral() function

include

TwoWire Wire1(&sercom2, // &PERIPH_WIRE 4, // PIN_WIRE_SDA 3); // PIN_WIRE_SCL

void setup() {

// Init Wire1 Wire1.begin(); Wire1.setClock(100000); pinPeripheral(4, PIO_SERCOM_ALT); pinPeripheral(3, PIO_SERCOM_ALT);

Serial1.begin(115200); }

void loop() {

Wire1.beginTransmission(0x40);

Wire1.write(0b101010); // Sends value byte Wire1.endTransmission(); // Stop transmitting

delay(500); } ` (set the parameters according to your i2c chip connected)

— Reply to this email directly, view it on GitHub https://github.com/arduino/ArduinoCore-samd/issues/711#issuecomment-2121905190, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBIOT7A4OPSUBFTENMY57VLZDLXANAVCNFSM6AAAAAA6GMLEM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRRHEYDKMJZGA . You are receiving this because you authored the thread.Message ID: @.***>