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
Welcome to the forum.
You need to post your code and you schematics for anyone to be able to see what's going on.
Read the "How to get the best out of this forum" article for instructions on how to do that - in particular, the sections "Posting code and common code problems" and "Schematics or circuit diagrams"
Some good, clear photos of your setup could also help.
My code and schematic are below:
// --------------------------------------
// i2c_scanner
//
// Version 1
// This program (or code that looks like it)
// can be found in many places.
// For example on the Arduino.cc forum.
// The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
// Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26 2013
// V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
// by Arduino.cc user Krodal.
// Changes by louarnold removed.
// Scanning addresses changed from 0...127 to 1...119,
// according to the i2c scanner by Nick Gammon
// https://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
// As version 4, but address scans now to 127.
// A sensor seems to use address 120.
// Version 6, November 27, 2015.
// Added waiting for the Leonardo SerialUSB communication.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//
#include <Wire.h>
#include "wiring_private.h" // pinPeripheral() function
TwoWire myWire(&sercom2, 4, 3);
void setup()
{
delay(5000);
myWire.begin();
pinPeripheral(4, PIO_SERCOM_ALT);
pinPeripheral(3, PIO_SERCOM_ALT);
SerialUSB.begin(9600);
while (!SerialUSB); // Leonardo: wait for SerialUSB monitor
SerialUSB.println("\nI2C Scanner");
}
void loop()
{
byte error, address;
int nDevices;
SerialUSB.println("Scanning...");
nDevices = 0;
for(address = 8; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
myWire.beginTransmission(address);
error = myWire.endTransmission();
if (error == 0)
{
SerialUSB.print("I2C device found at address 0x");
if (address<16)
SerialUSB.print("0");
SerialUSB.print(address,HEX);
SerialUSB.println(" !");
nDevices++;
}
else if (error==4)
{
SerialUSB.print("Unknown error at address 0x");
if (address<16)
SerialUSB.print("0");
SerialUSB.println(address,HEX);
}
}
if (nDevices == 0)
SerialUSB.println("No I2C devices found\n");
else
SerialUSB.println("done\n");
delay(2500);
// wait 2.5 seconds for next scan
}
LaunchV1.0.pdf (370.7 KB)
What is the value of the parts? I am mainly interested in the I2C pull up resistors. They should be in the 3K range.
The I2C pullups are 4.7 kOhms.
Normal I2C on 20 and 21 works with the same pull-up resistors.
You need to change the pin definitions for I2C. You can access pin definitions in the arduino15 folder I believe in the variants.h and variants.cpp files. If you are having trouble doing this, you can much more easily access the variant files if you are using platformio.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.