As the title says, I noticed that my Teensy 4.0 gets stuck when I upload a code which has both the audio library code (see code bellow) and analogRead() lines in it.
In this situation, the Teensy is stuck and does not show as connected to the computer. It is not recognized by the computer.
I can still reset it with the 15 sec button press and I can upload code if I press the button after the Arduino IDE compiles the code.
Here are two examples of code:
This works:
notice all the commented out lines
Also this works:
This does not work:
Notice I did not comment out the analogRead line.
Could this be a bug? I tried installing the Teensydoino 1.54 beta 9 but still the same result. I am using the latest Arduino IDE and Teensyduino.
What can I do to resolve this?
Thank you.
In this situation, the Teensy is stuck and does not show as connected to the computer. It is not recognized by the computer.
I can still reset it with the 15 sec button press and I can upload code if I press the button after the Arduino IDE compiles the code.
Here are two examples of code:
This works:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
// GUItool: begin automatically generated code
//AudioInputI2S i2s1; //xy=126,88
//AudioOutputI2S i2s2; //xy=448,94
//AudioConnection patchCord1(i2s1, 0, i2s2, 0);
//AudioConnection patchCord2(i2s1, 0, i2s2, 1);
//AudioControlSGTL5000 sgtl5000_1; //xy=259,148
// GUItool: end automatically generated code
void setup() {
Serial.begin(9600);
AudioMemory(8);
//sgtl5000_1.enable();
//sgtl5000_1.volume(0.5);
//sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
//sgtl5000_1.micGain(36);
delay(1000);
}
void loop() {
Serial.println("TEST");
Serial.println(analogRead(A10));
delay(1000);
}
Also this works:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=126,88
AudioOutputI2S i2s2; //xy=448,94
AudioConnection patchCord1(i2s1, 0, i2s2, 0);
AudioConnection patchCord2(i2s1, 0, i2s2, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=259,148
// GUItool: end automatically generated code
void setup() {
Serial.begin(9600);
AudioMemory(8);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(36);
delay(1000);
}
void loop() {
Serial.println("TEST");
//Serial.println(analogRead(A10));
delay(1000);
}
This does not work:
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=126,88
AudioOutputI2S i2s2; //xy=448,94
AudioConnection patchCord1(i2s1, 0, i2s2, 0);
AudioConnection patchCord2(i2s1, 0, i2s2, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=259,148
// GUItool: end automatically generated code
void setup() {
Serial.begin(9600);
AudioMemory(8);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
sgtl5000_1.micGain(36);
delay(1000);
}
void loop() {
Serial.println("TEST");
Serial.println(analogRead(A10));
delay(1000);
}
Could this be a bug? I tried installing the Teensydoino 1.54 beta 9 but still the same result. I am using the latest Arduino IDE and Teensyduino.
What can I do to resolve this?
Thank you.