Teensy 4.0 First Beta Test

Status
Not open for further replies.
ANALOGREFERENCE

Alcon, need a sanity check on the analog reference before I go crazy. I reread the section 65.5.2 in the RM on the Ref Voltage and the ADC_CFG[REFSEL] register. But looking REFSEL you only have one option, Vrefh and Vrefl, others choices are reserved. Then in the begining of the ADC section, "VREFH / VREFL are bonded to VDDA_ADC_3P3 / GND, on this device".

So if I am interpreting correctly, you can't change the analogreference like you can with the T3x
 
@mjs513 and ... Not sure how much help I can be with some of the Analog things... But will give my $.02 worth of comments :D

Hopefully someone who uses it more, can give hopefully give at least $.03

AnalogReference - Your guess is better than mine! But I think I am reading it the same way...

I do remember some discussions, about the analog capabilities are not as capable as T3, maybe trading off higher speeds and the like...

Things like:
T3.x can give up to 16 bit resolution, where these only 12 bit.
T3.x has some differential like stuff, not sure here about T4
Number of Inputs?
The 3.6 talks about Up to four pairs of differential and 24 single-ended external analog inputs
The 4 mentions: Up to 10 ENOB (dedicated single ended channels) and Up to 8 single-ended external analog inputs - Not sure difference

In some comments yesterday I asked about having special logical pins for Temp and VREF, like we have for T3.x...

Not sure if we can do for Temp, as on T3.x It is an actual actual Analog channel, example 26 first ADC on T3.6 on T4, I don't see any and there is a complete other chapter on Temperature monitoring. Could maybe hack up analog.c to detect special case and call over to temp monitoring code?

VRef: On T3.6 we use channel 18 on ADC1 which is: VREF Output/ADC1_SE18... Not sure if on T4 if setting: 11001 VREFSH = internal channel, for ADC self-test, hard connected to VRH internally Would give us anything?
Also not sure about ADC_ETC Stuff...


Again sorry, not much help.
 
I just hit the USBHost logger_RawWrite sketch and ...\libraries\uSDFS\src\utility\ff_utils.c needs some work on the Time with the update 1062 bootloader v4. I hacked it enough to compile - but not quite a valid time string ….

Update:
modified uSDFS to handle RTC also for T4
 
@KurtE - first, you are always a lot of help and give me a lot of background that I don't have. As for your other comments....

Right not functions for AnalogResolution and AnalogAverging are all operational for the Analog pins that are broken out. Not sure what the difference is between ENOB and single-ended external channels either. This is the first time I ever got down into the nuts and bolts of ADC. As for differential I don't remember seeing anything in the RM about it but … I know it does have compare capability.

Not sure if we can do for Temp, as on T3.x It is an actual actual Analog channel, example 26 first ADC on T3.6 on T4, I don't see any and there is a complete other chapter on Temperature monitoring. Could maybe hack up analog.c to detect special case and call over to temp monitoring code?
To be honest not sure its really worth it - when to get internal temp all you have to do in any sketch is do a: tempmonGetTemp(), results in deg C. We could do a hack it would be convoluted because wouldn't you expect it come out in counts, then the user has to do the conversion? Don't know never tried it on the T3.x

VRef: On T3.6 we use channel 18 on ADC1 which is: VREF Output/ADC1_SE18... Not sure if on T4 if setting: 11001 VREFSH = internal channel, for ADC self-test, hard connected to VRH internally Would give us anything?
Also not sure about ADC_ETC Stuff...
Yeah, I saw that as well but I think you need to put ADC into set test mode which would defeat the purpose I think. A little lost in the woods now with this one.

Anyway, thanks for the sanity check on the interpretation.

EDIT: Forgot, @manitou put up a sample sketch if I remember right for ADC_ETC.
 
EDIT: Forgot, @manitou put up a sample sketch if I remember right for ADC_ETC.

I have examples using internal DAC to do ADC compare, and using ADC_ETC to do timed ADC reads, and free-running ADC with double-buffered DMA, BUT i never found a way to do what audio lib needs: timed ADC with double-buffered DMA
 
MSC on T4 with latest TD?
Does someone from the MSC thread have MSC running with latest TD update?
In my case my program logger_RawWrite stops when writing the first data buffer (64 blocks)
I use a SSD disk with DIGITUS USB2 to SATA II adapter
I worked previously (when we were working on other thread)

Solved it (have nearly forgotten about it)
There needs to be a correction in "hardware\teensy\avr\libraries\USBHost_t36\ehci.cpp" line 748 to read
Code:
for (count=((len-1) >> 14); count; count--)
See https://forum.pjrc.com/threads/5582...er-Experiments?p=205836&viewfull=1#post205836
 
Last edited:
RadioHead - Appears to work for RFM95

However did not allow SPI1 and SPI2 to be used, so updated code to allow this: https://github.com/PaulStoffregen/RadioHead/pull/31

I have the simple Client Server code running with rfm95_client running on T4 on SPI - Had to remember to do a few edit changes: to set frequency...

I have it talking to one of my own boards for T3.6 on SPI1 which is running rfm95_server

And the two are talking.
 
RadioHead - Appears to work for RFM95

However did not allow SPI1 and SPI2 to be used, so updated code to allow this: https://github.com/PaulStoffregen/RadioHead/pull/31

I have the simple Client Server code running with rfm95_client running on T4 on SPI - Had to remember to do a few edit changes: to set frequency...

I have it talking to one of my own boards for T3.6 on SPI1 which is running rfm95_server

And the two are talking.

@KurtE - nice catch Kurt. Only tested SPI never thought about SPI1/2. PS. Ordered some breadboard pushbuttons to test USB joystick etc....
 
@WMXZ

Downloaded TD4.17B3 and installed a fresh copy of Arduino 1.89 Updated uSDFS to your latest version.
I ran 'logger_RawWrite.ino' on my seven different HD's and they are averaging 7.5MBs. Very consistent for all those drives. (Except for the one that I did not have the write cache turned on).

When compiling 'logger_RawWrite_FS.ino' though I am getting following compile error:
Code:
/home/wwatson/arduino-1.8.9/arduino-builder -dump-prefs -logger=machine -hardware /home/wwatson/arduino-1.8.9/hardware -hardware /home/wwatson/.arduino15/packages -tools /home/wwatson/arduino-1.8.9/tools-builder -tools /home/wwatson/arduino-1.8.9/hardware/tools/avr -tools /home/wwatson/.arduino15/packages -built-in-libraries /home/wwatson/arduino-1.8.9/libraries -libraries /home/wwatson/Arduino/libraries -fqbn=teensy:avr:teensy4b2:usb=serial,opt=o3std,keys=en-us -ide-version=10809 -build-path /tmp/arduino_build_114602 -warnings=none -build-cache /tmp/arduino_cache_382777 -verbose /home/wwatson/Arduino/libraries/uSDFS/examples/logger_RawWrite_FS/logger_RawWrite_FS.ino
/home/wwatson/arduino-1.8.9/arduino-builder -compile -logger=machine -hardware /home/wwatson/arduino-1.8.9/hardware -hardware /home/wwatson/.arduino15/packages -tools /home/wwatson/arduino-1.8.9/tools-builder -tools /home/wwatson/arduino-1.8.9/hardware/tools/avr -tools /home/wwatson/.arduino15/packages -built-in-libraries /home/wwatson/arduino-1.8.9/libraries -libraries /home/wwatson/Arduino/libraries -fqbn=teensy:avr:teensy4b2:usb=serial,opt=o3std,keys=en-us -ide-version=10809 -build-path /tmp/arduino_build_114602 -warnings=none -build-cache /tmp/arduino_cache_382777 -verbose /home/wwatson/Arduino/libraries/uSDFS/examples/logger_RawWrite_FS/logger_RawWrite_FS.ino
Using board 'teensy4b2' from platform in folder: /home/wwatson/arduino-1.8.9/hardware/teensy/avr
Using core 'teensy4' from platform in folder: /home/wwatson/arduino-1.8.9/hardware/teensy/avr
Detecting libraries used...
/home/wwatson/arduino-1.8.9/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++ -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=147 -DARDUINO=10809 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/home/wwatson/arduino-1.8.9/hardware/teensy/avr/cores/teensy4 /tmp/arduino_build_114602/sketch/logger_RawWrite_FS.ino.cpp -o /dev/null
/home/wwatson/Arduino/libraries/uSDFS/examples/logger_RawWrite_FS/logger_RawWrite_FS.ino:254:24: fatal error: sd_config.h: No such file or directory
compilation terminated.
Error compiling for board Teensy 4-Beta2.

If I copy sd_config.h directly to the src directory it compiles up to this error:
Code:
/home/wwatson/Arduino/libraries/uSDFS/examples/logger_RawWrite_FS/logger_RawWrite_FS.ino:446:55: warning: format '%d' expects argument of type 'int', but argument 4 has type 'uint32_t {aka long unsigned int}' [-Wformat=]
logger_RawWrite_FS: In function 'void rtc_init()':
logger_RawWrite_FS:487: error: 'SNVS_LPSR_PGD_MASK' was not declared in this scope
   SNVS_LPSR = SNVS_LPSR_PGD_MASK;
               ^
logger_RawWrite_FS:491: error: 'SNVS_LPCR_LPTA_EN_MASK' was not declared in this scope
   SNVS_LPCR &= ~SNVS_LPCR_LPTA_EN_MASK; // clear alarm
                 ^
Using library uSDFS at version 1.1.2 in folder: /home/wwatson/Arduino/libraries/uSDFS 
Using library USBHost_t36-PS3_Motion_WIP2-Bluetooth at version 0.1 in folder: /home/wwatson/arduino-1.8.9/hardware/teensy/avr/libraries/USBHost_t36-PS3_Motion_WIP2-Bluetooth 
Using library MSC at version 1.0.0 in folder: /home/wwatson/Arduino/libraries/MSC 
'SNVS_LPSR_PGD_MASK' was not declared in this scope

I am probably missing something.
 
Understandable, lot's going on right now. I am having a hard time keeping up with all the changes. Need more free time:)
 
Understandable, lot's going on right now. I am having a hard time keeping up with all the changes. Need more free time:)

That came with the latest T4 bootloader update with the RTC started and set during upload. So those services are now native available in some fashion. Recent post manitou published and I edited replublished a RTC time sample - not sure if that is the answer - it returns time: See " time_t tt = rtc_get(); "
 
I thought I might take a quick look at some of the avr_emulation code for SPI that is not currently implemented.

I hope it is fine, but I am finding that some of this code is using some of the functions like: void serial_print(const char *p);
to print out stuff to Serial1... So I defined a few of these in HardwareSerial.h and implemented them in HardwareSerial1.cpp

They are defined in the extern "C" block of the header file so should be defined as C bindings...

Note: These changes are in the branch I have that is part of the SerialEvents/main Pull Request
 
@mjs513 and...
@KurtE - nice catch Kurt. Only tested SPI never thought about SPI1/2. PS. Ordered some breadboard pushbuttons to test USB joystick etc....
I would have probably missed it as well, except my T3.6 board uses SPI1 and I tried to compile the edited version of the simple client/server I previously updated to run on SPI1...

Edit: Will later try the SPI1 code on T4, when my break out board arrive from Seeed... They shipped and I do have setup to solder on RFM95 on SPI1. But not sure yet, may wait until I can buy a T4 as it will require me to solder on the surface mount connectors like we have on T3.x... And not sure if I want to risk the current test board, as I won't be able to then take it out and plug into PJRC breakout board.

As for USB Joystick, testing, I may try to simply use one of the Arbotix Commanders (shield), that I have as part of my Trossen stuff:
ASS-ARBX-CMD-V2-b.jpg


It has two thumb like axis, plus 8 buttons, and they ship it plugged into an Seeedstudio simple Arduino board (runs at 3.3v) So should be easy to try out, especially if you have a T4 board with Arduino shield connectors ;)
 
@KurtE
Trossen has some nice stuff I see - never saw that before though. Going to be interesting. Figure with the push buttons and thumb pots I might be able to test a couple of more things. The new version of my breakout board is coming next week (DHL holdup) so will have to play and test that with the SMD components - going to be fun soldering. I am using the T4B2 with the brownout fix mainly for the same reason you stated - didn't want to ruin it so I couldn't use it for testing in Paul's breakout which I really like
 
@KurtE
The new version of my breakout board is coming next week (DHL holdup) so will have to play and test that with the SMD components - going to be fun soldering. I am using the T4B2 with the brownout fix mainly for the same reason you stated - didn't want to ruin it so I couldn't use it for testing in Paul's breakout which I really like
Sounds good - Mine shipped From Seed on 6/4, but update says that today: Depart from facility to service provider. (USPS) Not sure how long it will take....

I probably should do a parts list and make an order to have at least some of the parts on hand... Sort of figure I may have some time... Again not sure when T4 will ship, but I can probably sacrifice the older T4B2, although it does not have the same SD connector so probably would not hook up that part.
 
@KurtE, @defragster, @Frank B, etc

Last night I was looking for stuff on Arduino or Teensy with HDMI and came across a shield somebody designed for to out HDMI from a Teensy 3.5/3.6. While not directly related to the T4 thought I would post it here as a FYI. Heres a link to the YouTube video, https://www.youtube.com/watch?v=MUeIY_gLn3c, the interesting piece on the T3.5/3.6 starts at 2:55.
 
@all
I thought I would look at the loop timing, with how much time is being used, in particular how much time is added by calling yield() and where the time is used and how to make quicker...

Right now playing with simple sketch:
Code:
uint32_t start_time;
int loop_counter = 0;
elapsedMicros micros_timer = 0;
void setup() {
  pinMode(13, OUTPUT);
  while (!Serial) ;
  Serial.begin(115200);
  micros_timer = 0;
  start_time = micros();
  for (loop_counter = 0; loop_counter < 1000; loop_counter++) {
    digitalWriteFast(13, !digitalReadFast(13));
  }
  uint32_t dt = micros()-start_time;
  Serial.printf("For: %d %d\n", dt, micros_timer);
  delay(1000); // give lots of time to print...
  loop_counter = 0;
  micros_timer = 0;
  start_time = micros();
}


void loop() {
  digitalWriteFast(13, !digitalReadFast(13));
  loop_counter++;
  if (loop_counter == 1000) {
    uint32_t dt = micros()-start_time;
    Serial.printf("Lop: %d %d\n", dt, micros_timer);
    delay(1000); // give lots of time to print...
    loop_counter = 0;
    start_time = micros();
    micros_timer = 0;
  }
}
And finding either elapsedMicros is not working or I am not using it right...

Doing some comparisons of time to do the 1000 iterations of the digitalWriteFast(13, !digitalReadFast(13))

The one called in setup in a straight loop is taking: 26 us
Loop not calling yield: 72
Loop calling yield but yield does nothing: 96
Yield only calls EventResponder::runFromYield() : 137
Add quick check at start of runFromYield ( if (!firstYield) return;): 102
Will add to my PR...

Now add back: if (usb_enable_serial_event_processing && Serial.available()) serialEvent(); Plus the no recursion code: that is Yield is:
Code:
void yield(void)
{
	static uint8_t running=0;

	if (running) return; // TODO: does this need to be atomic?
	running = 1;


	// USB Serail - Add hack to minimize impact...
	if (usb_enable_serial_event_processing && Serial.available()) serialEvent();

	running = 0;
	EventResponder::runFromYield();
	
};
The (usb_enable_serial_event_processing is a hack I put in to the default SerialEvent which turns it off)
Run with: 145 If I enter something in Serial Monitor: 131

Now if I add back in the call to the HardwareSerial::processSerialEvents();
right after the USB test code: It jumps back up to: 163 (Down to 150 if Character entered in USB...)

Now if I move the check to see if there are any SerialEvent functions active from the processSerialEvents
into making the call conditional within yield: 154(153 alternating) and 139 after usb key in...
So may also Make that change as well...

As for elapsed Micros I probably should take a look, here is extract of the last run:
Code:
For: 26 536877268
Lop: 153 536877268
Lop: 153 536877268
Lop: 153 536877268
Lop: 154 536877268
Lop: 154 536877268
Lop: 153 536877268
Lop: 139 536877268
Lop: 139 536877268

EDIT: elapsedMicros - issue was not with it, but simply using in Serial.printf.

That is if I change first print to: Serial.printf("For: %d %d\n", dt, (uint32_t)micros_timer);
It works fine
 
Last edited:
PHEW - That is Good that elapsedMicros is healthy - it runs off the ARM_CycCnt micros() . Yeah - (casting) shows up in those warning notes that scroll off in the verbose compile cloud.

Just remembered one other old tidbit reading that - need to find/test the sketch - where DigRead/Write had diff timings on 1052 depending on if there was a 1 or a 0 involved in the state in some fashion.

@mjs513 and HDMI - big board - but cool: github.com/techtoys/HDMI-Shield/tree/master/Ra8876_Lite
Teensy 3.2 and 3.5 with a simple stacker PCB (Teensy Stacker DTE20171030). Teensy is providing the best Audio library for Arduino platform in my opinion. WAV file playback is used in the example Ra8876_allegro_bruce_xflash.ino for a very famous Bruce Lee movie sound track as the background music while three gif animations are played. You will need a HDTV or FHD monitor with HDMI interface to hear this.
 
@mjs513 - This is what I am using with my T36 configured for SPI: https://www.buydisplay.com/default/serial-spi-i2c-10-1-inch-tft-lcd-module-dislay-w-ra8876-optl-touch-panel
It also uses the RAIO RA8876 display controller with XPT2046 touch screen. My software driver is a heavily modified version of RA8876_Lite. The controller board is mounted behind the display.
I want to adapt this for use with the T4. Hopefully this not off topic. This display has the same MISO tristate problem as the RA8875. So at this point I am using all three SPI ports on the T36. One for the display, one for the touch screen and one for use with WIFISPI and the ESP8266.
 
Hi @wwatson - It has been awhile since we played with it, but Mike does have the driver: https://github.com/mjs513/ILI9488_t3
Which I believe I tested on SPI2 of the T4 (I think it was with the T4B1...) maybe should retry again with T4B2 (Cable version).

I used a Sparkfun SDCard breakout adapter to get access to the IO pins and then tried it out. I have not tried it yet on SPI1 as I don't have breakout board which had easy access to all of the bottom SMT pads.

I also have the ability to use Flex IO pins to create another SPI port, May not be great for display, but probably could easily be used for touch...
 
@degragster - yes its a big but no bigger than an Arduino Uno and it does use 3.3v so should work with the T4. Right now the website shows that it does not have any available but I contacted the gentlemen and he said he a few left so trying to get one to test with the T4. :) Just can't resist the lure of hooking up the T4 to a HDMI screen.

@wwatson/@KurtE - nice setup, only just got into the displays stuff when I started with playing with the ILI9488_t3 library with @KurtE so never even heard of the RA8875 stuff before so looks like its going to be interesting to get it too work. As for the tristate issue - haven't had time to play with it to see if I could get it too work with the one of those tristate buffers - maybe that will be the next project - right other distractions got my attention today and probably tomorrow.

Same here on testing of the ILI9488 display on SPI1 - only tested it on SPI and SPI2. But it is configured that you can use SPI1. Same with ILI9341_t3n.
 
@wwatson/@KurtE - the Touch on the 9488 I had was tri-stated safe - so it could share SPI with other and it was only the MISO on 9488 that was trouble when needed to read the display. Thought the _isr INT detect was a bit odd perhaps - maybe that was 1052 testing - or how it was hacked to work … one more thing to revisit.

@mjs513 - Big for the HDMI is relative ;) - given it gets to an HDMI screen of rPi size or big screen. Nice that uses a supported controller interface - should be cleaner and better than analog VGA where it loaded the MCU (pins and timing) and got digital noise in the signal. Good you found availability details - hopefully cost effective and they make more?
 
@defragster - from what I read it's about $61 dollars for the shield but it also ships with a stm32 something or other that goes between the Arduino and the Shield. If you use a teensy you don't need that extra piece. Think he wrote something in the youtube comments about looking at a redesign for improvements and easier production. The company is in Hong Kong.
 
Status
Not open for further replies.
Back
Top