Teensyduino 1.52 Beta #2

Status
Not open for further replies.

Paul

Administrator
Staff member
Here is a second beta test for Teensyduino 1.52.


Edit: links removed, please use 1.52-beta5.


Changes since Teensyduino 1.52-beta1:

Fix USB RawHID on Teensy 4.0 (KurtE)
Fix USB audio+midi+serial descriptor on Teensy 4.0 (widdly)
Add ADK to USBHost_t36 (Matt Bergman)
Fix USB Host MIDI transmit race condition (essej)
Optimize USB interrupt on Teensy 4.0 (Frank B)
Arduino compatibility of digitalWrite control pullups (FrankB)
Add missing MPU traps on Teensy 4.0 (FrankB)
Fix SGTL5000 clock ratio setting (FrankB)
Fix I2S slave on Teensy 4.0 (widdly)
Add DMAMEM & fix warnings in I2S on Teensy 4.0 (FrankB)
Improve SPI use by SD on Teensy LC (rutmarti)
Support alternate SPI pins on Teensy 4.1 (KurtE)
Support alternate Teensy 4.1 CS pins on ILI9341_t3 (KurtE)
Fix Teensy Loader on MacOS 10.13 with Catalina version
Fix teensy_serialmon 100% CPU on Linux if Arduino process killed
Workaround for rare Windows Defender flase positive when installing Java classes
 
Hi Paul.
I'm sorry to bother you but I think the mic input have lost it's functionality in 1.52 Beta #2.
hardware Teensy 4 + Teensy Audio adapter Rev D

I have it tested with a simple script using a clean Arduino 1.8.12 + Teensyduino 1.52 Beta #1 install vs Arduino 1.8.12 + Teensyduino 1.52 Beta #2.
With Beta #2 there is no input signal from mic and some times there is clock & data lines noise mixed with the audio.

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioInputI2S            mic1; //xy=454,353
AudioOutputUSB           usboutput1; //xy=727,411
AudioOutputI2S           spk1; //xy=738,357
AudioConnection          patchCord1(mic1, 0, spk1, 0);
AudioConnection          patchCord2(mic1, 0, spk1, 1);
AudioConnection          patchCord3(mic1, 0, usboutput1, 0);
AudioConnection          patchCord4(mic1, 0, usboutput1, 1);
AudioControlSGTL5000     audioShield; //xy=669,235

void setup() {
  AudioMemory(16);
  audioShield.enable();
  audioShield.volume(0.6f);
  audioShield.inputSelect(AUDIO_INPUT_MIC);
  audioShield.micGain(33);
}

void loop() {
}

I have connected a ILI9341 on alternate SPI pins and the full setup (sort of usb audio card image below) was working flawlessly since the first commit with usb audio suport you make to the cores git till this Beta #2
2020-04-07_19-36.png

Thanks for all your magnificent work.
 
Hi!

I'm still getting clicks and discontinuities with the USB Audio In/Out after around 20 seconds or so. Same results on both macOS 10.12 and iOS 12.

I wonder if anybody has similar problems and/or suggestions on how to fix it? Looks like it's sending a bunch of zeros:

sine glitch.png

I'd post the source code, but it's more or less copied straight from the Audio Design Tool. InputI2S -> OutputUSB and vice versa. Audio passthrough via I2S works without any issues.
 
Hi!

I'm still getting clicks and discontinuities with the USB Audio In/Out after around 20 seconds or so. Same results on both macOS 10.12 and iOS 12.
...
I'd post the source code, but it's more or less copied straight from the Audio Design Tool. InputI2S -> OutputUSB and vice versa. Audio passthrough via I2S works without any issues.

Prior post in Beta 1 - had a detail or two : Teensyduino-1-52-Beta-1

Note: "more or less copied" - is not a sketch for repro Paul could open - connect - run - and see the problem. Feel free to post exact code - with needed hardware connects parts ( Teensy x.x? and Audio board rev 'letter' ) and connects - that would Copy&Paste to the IDE and demo the issue.
 
Teensy 3 or Teensy 4?

Oh, sorry! It's a Teensy 4.0 I'm using.

Prior post in Beta 1 - had a detail or two : Teensyduino-1-52-Beta-1

Note: "more or less copied" - is not a sketch for repro Paul could open - connect - run - and see the problem. Feel free to post exact code - with needed hardware connects parts ( Teensy x.x? and Audio board rev 'letter' ) and connects - that would Copy&Paste to the IDE and demo the issue.

Unfortunately I don't have an Audio Board here. I'm using a custom board with a CS4272 and edited AudioControlCS4272.h to configure the codec as Slave. However, I didn't think that this could cause the problem, since the I2S In/Out itself works without any issues. Sorry for the confusion!

Anyway, the problem also appears when routing AudioSynthWaveformSine to the USB output and monitoring through the built-in speakers of my mac, like this for example:

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioSynthWaveformSine   sine1;          //xy=151,269
AudioOutputUSB           usb2;           //xy=382,258
AudioOutputI2S           i2s1;           //xy=410,142
AudioConnection          patchCord1(sine1, 0, usb2, 0);
AudioConnection          patchCord2(sine1, 0, usb2, 1);
// GUItool: end automatically generated code

void setup() {
  AudioMemory(20);
  sine1.frequency(440);
  sine1.amplitude(0.8);
}

void loop() {
  while(1);
}
 
Ciao. Now I've tried Teensyduino 1.52beta2 with the followng test code:
Code:
#define MUTEPIN 6
#define PDNPIN 22

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

#include "chords.h"

// Special thanks to Matthew Rahtz - http://amid.fish/karplus-strong/



// GUItool: begin automatically generated code
AudioSynthKarplusStrong string1; //xy=55,267
AudioSynthKarplusStrong string6; //xy=153,213
AudioMixer4 mixer1; //xy=166,387
AudioInputI2S i2s1; //xy=245,101
AudioSynthKarplusStrong string5; //xy=312,190
AudioSynthKarplusStrong string2; //xy=435,153
AudioMixer4 mixer2; //xy=474,444
AudioSynthKarplusStrong string3; //xy=541,252
AudioSynthKarplusStrong string4; //xy=570,134
AudioOutputI2S i2s2; //xy=667,491
AudioOutputSPDIF2 spdif2; //xy=704,401
AudioConnection patchCord1(string1, 0, mixer1, 0);
AudioConnection patchCord2(string6, 0, mixer2, 2);
AudioConnection patchCord3(mixer1, 0, mixer2, 0);
AudioConnection patchCord4(i2s1, 0, mixer2, 3);
AudioConnection patchCord5(i2s1, 1, i2s2, 1);
AudioConnection patchCord6(string5, 0, mixer2, 1);
AudioConnection patchCord7(string2, 0, mixer1, 1);
AudioConnection patchCord8(mixer2, 0, spdif2, 0);
AudioConnection patchCord9(mixer2, 0, spdif2, 1);
AudioConnection patchCord10(mixer2, 0, i2s2, 0);
AudioConnection patchCord11(string3, 0, mixer1, 2);
AudioConnection patchCord12(string4, 0, mixer1, 3);
// GUItool: end automatically generated code



const int finger_delay = 5;
const int hand_delay = 220;

int chordnum = 0;

void setup() {
  pinMode(MUTEPIN, OUTPUT);
  digitalWrite (MUTEPIN, 0);
  pinMode(PDNPIN, OUTPUT);
  digitalWrite (PDNPIN, 0);
  AudioMemory(30);
  float gain = 0.15;
  //float gain = 0;
  mixer1.gain(0, gain);
  mixer1.gain(1, gain);
  mixer1.gain(2, gain);
  mixer1.gain(3, gain);
  mixer2.gain(1, gain);
  mixer2.gain(2, gain);
  delay(700);
  digitalWrite (PDNPIN, 1);

}

void strum_up(const float *chord, float velocity);
void strum_dn(const float *chord, float velocity);

void loop() {
  const float *chord;

  // each time through the loop, play a different chord
  if (chordnum == 0) {
    chord = Cmajor;
    Serial.println("C major");
    chordnum = 1;
  } else if (chordnum == 1) {
    chord = Gmajor;
    Serial.println("G major");
    chordnum = 2;
  } else if (chordnum == 2) {
    chord = Aminor;
    Serial.println("A minor");
    chordnum = 3;
  } else {
    chord = Eminor;
    Serial.println("E minor");
    chordnum = 0;
  }

  // then strum the 6 string several times
  strum_up(chord, 1.0);
  delay(hand_delay);
  delay(hand_delay);
  strum_up(chord, 1.0);
  delay(hand_delay);
  strum_dn(chord, 0.8);
  delay(hand_delay);
  delay(hand_delay);
  strum_dn(chord, 0.8);
  delay(hand_delay);
  strum_up(chord, 1.0);
  delay(hand_delay);
  strum_dn(chord, 0.8);
  delay(hand_delay);
  strum_up(chord, 1.0);
  delay(hand_delay);
  delay(hand_delay);
  strum_up(chord, 1.0);
  delay(hand_delay);
  strum_dn(chord, 0.7);
  delay(hand_delay);
  delay(hand_delay);
  strum_dn(chord, 0.7);
  delay(hand_delay);
  strum_up(chord, 1.0);
  delay(hand_delay);
  strum_dn(chord, 0.7);
  delay(hand_delay);

  Serial.print("Max CPU Usage = ");
  Serial.print(AudioProcessorUsageMax(), 1);
  Serial.println("%");
}

void strum_up(const float *chord, float velocity)
{
  if (chord[0] > 20.0) string1.noteOn(chord[0], velocity);
  delay(finger_delay);
  if (chord[1] > 20.0) string2.noteOn(chord[1], velocity);
  delay(finger_delay);
  if (chord[2] > 20.0) string3.noteOn(chord[2], velocity);
  delay(finger_delay);
  if (chord[3] > 20.0) string4.noteOn(chord[3], velocity);
  delay(finger_delay);
  if (chord[4] > 20.0) string5.noteOn(chord[4], velocity);
  delay(finger_delay);
  if (chord[5] > 20.0) string6.noteOn(chord[5], velocity);
  delay(finger_delay);
}

void strum_dn(const float *chord, float velocity)
{
  if (chord[5] > 20.0) string1.noteOn(chord[5], velocity);
  delay(finger_delay);
  if (chord[4] > 20.0) string2.noteOn(chord[4], velocity);
  delay(finger_delay);
  if (chord[3] > 20.0) string3.noteOn(chord[3], velocity);
  delay(finger_delay);
  if (chord[2] > 20.0) string4.noteOn(chord[2], velocity);
  delay(finger_delay);
  if (chord[1] > 20.0) string5.noteOn(chord[1], velocity);
  delay(finger_delay);
  if (chord[0] > 20.0) string6.noteOn(chord[0], velocity);
  delay(finger_delay);
}
Teensy 4.0
The I2S codec is AK4556VT on I2S1.
The S/PDIF output is just a LED on pin2.
With the original input_i2s.cpp, the input of sound soes not work.
then I replaced that with the one from post #5
. The I2S input test works partially, but during compile throws this output:
Code:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Audio\input_i2s.cpp: In static member function 'static void AudioInputI2S::isr()':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Audio\input_i2s.cpp:125:52: warning: invalid conversion from 'const void*' to 'void*' [-fpermissive]

    arm_dcache_delete(src, sizeof(i2s_rx_buffer) / 2);

                                                    ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/core_pins.h:32:0,

                 from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/wiring.h:39,

                 from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/WProgram.h:45,

                 from C:\Users\Angelina\AppData\Local\Temp\arduino_build_881006\pch\Arduino.h:6:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/imxrt.h:9124:20: note:   initializing argument 1 of 'void arm_dcache_delete(void*, uint32_t)'

 static inline void arm_dcache_delete(void *addr, uint32_t size)

                    ^

Opening Teensy Loader...

Sketch uses 32960 bytes (1%) of program storage space. Maximum is 2031616 bytes.
Global variables use 53940 bytes (10%) of dynamic memory, leaving 470348 bytes for local variables. Maximum is 524288 bytes.
As said, I2S input works partially. It shows high distortion, as if not every sample is read.
Also, the I2S output has now or then a very short dropout, or short episodes of slight distortion, while the S/PDIF plays clear signal.
I've checked the signals to the chip. They are very clear and rectangular, using in-line resistors, but have quite sime timing jitter.
pin23 MCLK seems to have the same jitter. It looks like there is something not stable with the frequencies/PLLs. The phases do not show constant lengths.

The settings of the AKM are classic I2S. normal speed, proven many times on other I2S devices:
Mode 5, CKS3=L, CKS2=H, CKS1=L, CKS0=H, I2S slave
De-emphasis off, DEM1=L, DEM0=H

So this should be pretty standard.
 
Last edited:
Other issue: Sometimes, without making sense why, the Teensy 4 crashes during upload. It can then only be recovered by pressing the buttin for 15 seconds until the redt blips, then after a while, there is the orange blink. Closing Teensyduino/Arduino and the loader. disconnecting from USB, reconnecting and repating compile and program works.
There seems to be no other way to recover the Teensy, because once it crashes during an upload, it remains so even if disconnected and reconneced or the Teensyduino and loader closed or reboot PC.
Looks like the Teensy is then pretty much messed, so the long button press is the only way back to work.
This happens on PC amd also on laptop, Windows 10 x64, also different USB cables, all tried.

forgot: When Teensy crashes, the loader shows something like "Erase Error" in red after a while
 
@Deleted User - have not seen that before? "Erase Error" or other upload fails as described. That seems to suggest a failure of the storage EEPROM - or other damage preventing full function.

The TeensyLoader program offers 'Verbose info' under the Help menu item.

With the sketch ready to upload { a Verify build in the IDE } open the verbose info and clear the Log perhaps.

Then try the upload { a button press after Verify } and if it fails then save that log info and upload the file for Paul's review.

If it works to upload repeat the log clear and retry so any events or feedback going along with the 'Erase Error' are captured in whatever detail is exposed.
 
The error happens not always. Today it was 2 times on the one Teensy 4 that is left here.
This one has maybe 50 uploads on the flash, never used something like eeprom library, so the memory should be ok.
Also it has never been exposed to radiation, temperature, moisture or magnetic fields other than natural home ambient.
Never used any power supply other than USB, never connected anything other than the AKM, the LED, and a perfectly working SPI ST7789 1.3'' display, all on 3.3V, so there should be everything ok with that aspect.
The supply and the 3.3V looks clean, but further more I did not scope into the Teensy 4, like crystals or so, because it is too tiny to probe by hand and the test rig is in our lab, not here.
 
Interesting - that sounds uncalled for :( Leaving the Verbose open and hitting Clear before each Upload will capture the transfer messages. If it fails then SAVE the log file and post it to get whatever is recorded so Paul can see it.
 
I've never had this too, even with a hundrets of uploads.
Damaged USB cable? A weird ground-loop? Something is very strange with your setup, because I2S works perfect for me, too. Even with 256k Samplerate (PCM1808 + 5104)
 
@defragster
Yesterday I had the issue several times. Today twice. Since I've read your post I did several uploads to provoke the error, but no problem. The next time I'll post the log here.
 
I've never had this too, even with a hundrets of uploads.
Damaged USB cable? A weird ground-loop? Something is very strange with your setup, because I2S works perfect for me, too. Even with 256k Samplerate (PCM1808 + 5104)

No ground loop, just the USB cable, nothing else connected to AKM, the first time the error came. So I changed the USB cable. The next time I changed the computer. Once connected amp to AKM, once nothing, because working on display. Usually I disconnect the audio line before flashing, anyway, so how could be the gound loop? During run no problem shows, also no ground loop noise if connected to amp.
You can be harsh to me, but I keep calm.
Maybe this one Teensy 4 has broken/faulty crystal. That would also explain issues with I2S signals.
 
Paul - Time setting to T_4.0 SRTC is not done in TD 1.52b2 :: See post or two above this one :: TimeTeensy3-example-gt-Time-chosen-is-not-permanent

Also noted in that post - whenever TeensyLoader runs from THIS PC the time showing on the Teensy is 'BACK' one hour!

Using the code in that linked thread the time can manually be advanced one hour to make it match PC time, Then on new UPLOAD the time is Always set back one hour again.

Here is the code in use calling suggested code to set SRTC time on T_4.0 from sketch with renamed function:: Rrtc_set()
Code:
//  https://forum.pjrc.com/threads/45377-TimeTeensy3-example-gt-Time-chosen-is-not-permanent?p=235414&viewfull=1#post235414
#include <TimeLib.h>            // https://github.com/PaulStoffregen/Time

time_t clock;
int i = 0;

void setup()
{
	Serial.begin(115200);
	while (!Serial && millis() < 4000 );
	Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);

	// set the Time library to use Teensy 4.0's RTC to keep time
	setSyncProvider(getTeensy3Time);
	setSyncInterval(60);
	getTeensy3Time();
	if (timeStatus() != timeSet) Serial.println("Init: RTC -> Unable to sync with the RTC");
	else Serial.println("Init: RTC has set the system time");
}

void loop()
{
	i = check_btn(); // read which button has been pressed

	if (i == 1)  RTC_Time_set(60); // + 1 minute
	if (i == 2)  RTC_Time_set(-60); // - 1 minute
	if (i == 10)  RTC_Time_set(+3600); // + 1 hour
	if (i == 20)  RTC_Time_set(-3600); //  - 1 hourB

	display_time();  // show time on screen
}

time_t getTeensy3Time()
{
	return Teensy3Clock.get();
}

void RTC_Time_set(int x)  // add x seconds
{
	clock = now();
	setTime(clock + x);
	delay(100);
	//Teensy3Clock.set(now());
	Rrtc_set(now());
}

int check_btn()
{
	if (Serial.available() > 0)
	{
		String data = "";
		char x;
		while (Serial.available())
		{
			x = Serial.read();

			if (isDigit(x))
				data += x - '0';
		}
		return data.toInt();
	}
	return 0;
}

void display_time()
{
	char s[10];
	sprintf(s, "%02d:%02d:%02d", hour(), minute(), second());
	Serial.println(s);
	delay(1000);
}

void Rrtc_set(unsigned long t)
{
   // stop the RTC
   SNVS_HPCR &= ~(SNVS_HPCR_RTC_EN | SNVS_HPCR_HP_TS);
   while (SNVS_HPCR & SNVS_HPCR_RTC_EN); // wait
   // stop the SRTC
   SNVS_LPCR &= ~SNVS_LPCR_SRTC_ENV;
   while (SNVS_LPCR & SNVS_LPCR_SRTC_ENV); // wait
   // set the SRTC
   SNVS_LPSRTCLR = t << 15;
   SNVS_LPSRTCMR = t >> 17;
   // start the SRTC
   SNVS_LPCR |= SNVS_LPCR_SRTC_ENV;
   while (!(SNVS_LPCR & SNVS_LPCR_SRTC_ENV)); // wait
   // start the RTC and sync it to the SRTC
   SNVS_HPCR |= SNVS_HPCR_RTC_EN | SNVS_HPCR_HP_TS;
}
 
Guys, can someone give me a quick. What is teesnyduino explanation?

Is it a replacement for the IDE? Do I still need the original Arduino IDE? From my ignorant user's point of view, everything has changed and I haven't been able to find an explanation as to what I have here.

Thanks!

-jim lee
 
Guys, can someone give me a quick. What is teesnyduino explanation?

Is it a replacement for the IDE? Do I still need the original Arduino IDE? From my ignorant user's point of view, everything has changed and I haven't been able to find an explanation as to what I have here.

Thanks!

-jim lee
Teensydunio is an addition to the original Ardunio IDE. You first install the Arduino IDE (1.8.12 being the current release), and then run the Teensydunio program, and it modifies your Arduino IDE to have Teensy support.
 
Teensydunio is an addition to the original Ardunio IDE. You first install the Arduino IDE (1.8.12 being the current release), and then run the Teensydunio program, and it modifies your Arduino IDE to have Teensy support.

With the exception for the Newer Mac installer - IIRC - where secure install has them bundled:
TeensyduinoInstall.dmg 79M

TeensyduinoInstall.exe 67M

TeensyduinoInstall.linux32 66M

TeensyduinoInstall.linux64 67M

TeensyduinoInstall.linuxaarch64 85M

TeensyduinoInstall.linuxarm 84M

Teensyduino_MacOS_Catalina.zip 283M
 
Status
Not open for further replies.
Back
Top