Teensy 2.0 clone I2C & USB conflict

Status
Not open for further replies.

joe_prince

Well-known member
I'm trying to make a clone of the Teensy 2.0 (which uses the ATMEGA32U4 chip) for a project. I have successfully burned the Leonardo bootloader, Caterina (https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/bootloaders/caterina), to the board using an Arduino Uno as the ISP. After hooking the ATMEGA32U4 board up to the computer via USB, I can successfully upload sketches from the Arduino IDE to the board. Sketches that blink an LED or read a potentiometer work fine, and I can print the values to the serial monitor over USB with no issues.

The problem comes though when I'm running an I2C sketch and try to print the values to the serial monitor. Uploading an I2C sketch to the board works fine, and I'm getting the correct output over the bus as verified with my oscilloscope (using an Adafruit compass (https://www.adafruit.com/products/1746) with this sketch: https://github.com/adafruit/Adafruit_HMC5883_Unified/blob/master/examples/magsensor/magsensor.ino). If I let the sketch run with the serial monitor closed, all is well and the scope gets the correct I2C readings. As soon as I open the serial monitor, though, the sketch stops running and the scope shows no data being sent over the I2C bus.

When I open the serial monitor sometimes it prints a few lines before locking up, and sometimes it locks up right away. If I run just I2C by itself without trying to print values to the serial monitor, it works fine. And if I just print values to the serial monitor without running I2C, that works fine as well. The problem is occurring when I2C and the serial monitor are running at the same time.

I have verified that the compass is working fine over I2C with other boards (such as an Arduino Uno, Teensy 2.0, and Teensy 3.2), and I have tried other I2C devices as well but all exhibit the same behavior.

This is a picture of the circuit I'm testing with, as well as a schematic:

ATMEGA32U4-circuit.jpg

ATMEGA32U4-schematic.jpg

I have kept the USB lines (D+ and D-) as short as possible, just going through the 22 ohm resistors directly into the ATMEGA32U4 pins, and have decoupling caps on all power lines. I've created the circuit on 2 different breadboards with a different set of components and chip, and it's still showing the same behavior so I don't believe it's an issue of a bad capacitor, loose connection on the board, bad solder joint, faulty USB cable, etc. I've also verified that I'm getting a steady 5V output from the USB line with little noise. Additionally, I've tried with 4.7k and 10k pull up resistors on the I2C lines and that didn't do anything to help the issue either.
 
Last edited:
Status
Not open for further replies.
Back
Top