Hi.
I have been using Teensy 4.0 and the audio shield to synthesize and output audio. Now I also need to send data out on a hardware serial port to control a second microcontroller (Arduino Nano v3).
It seems that sending of data through a serial port stops working when an instance of AudioOutputI2S is included in my code (i have tried TX1, TX2, TX6 and TX7). Without this instance the transmit behaves as expected.
My first thought was that the AudioOutputI2S object was reserving the pins, but looking at the source code (https://github.com/PaulStoffregen/Audio/blob/master/output_i2s.cpp) they do not appear to be used.
I created the simple example below. When the I2s1 object is included, the byte being transmitted by HWSERIAL.write(c); will not be received by the nano. For this example I am using pins 28 and 29 (Serial7).
I should mention that this is my first Arduino/Teensy project and I'm learning as I go along. Any help or guidance on this issue would be most appreciated. If this is the expected behaviour then I will search for some other workaround.
Thanks in advance,
Chris.
I have been using Teensy 4.0 and the audio shield to synthesize and output audio. Now I also need to send data out on a hardware serial port to control a second microcontroller (Arduino Nano v3).
It seems that sending of data through a serial port stops working when an instance of AudioOutputI2S is included in my code (i have tried TX1, TX2, TX6 and TX7). Without this instance the transmit behaves as expected.
My first thought was that the AudioOutputI2S object was reserving the pins, but looking at the source code (https://github.com/PaulStoffregen/Audio/blob/master/output_i2s.cpp) they do not appear to be used.
I created the simple example below. When the I2s1 object is included, the byte being transmitted by HWSERIAL.write(c); will not be received by the nano. For this example I am using pins 28 and 29 (Serial7).
Code:
#include <Audio.h>
//AudioOutputI2S i2s1; // <<< RE-ADDING THIS LINE STOPS ALL OUTPUT ON THE HW SERIAL PORTS
AudioControlSGTL5000 sgtl5000_1;
#define HWSERIAL Serial7
void setup() {
Serial.begin(9600);
HWSERIAL.begin(9600);
AudioMemory(10);
sgtl5000_1.enable();
sgtl5000_1.volume(0.8);
}
unsigned long g_lastSendTime = micros();
int c = 0;
void loop() {
unsigned long now = micros();
if(now - g_lastSendTime > 30000)
{
g_lastSendTime = now;
HWSERIAL.write(c);
c++;
if(c == 255) c = 0;
}
}
Thanks in advance,
Chris.