Stupid questions for Teensy 3.6

Status
Not open for further replies.

slam7211

New member
Just got my new 3.6, looked at what it came with, and it looks to be USB powered, which is 5V, but it also mentions that the pins are only 3.3V max. Haven't plugged mine in yet, just want to doublecheck, a standard 5V PC usb port will work correct?
 
yes, the 5V from USB is regulated down to 3.3V by the teensy.
The warning means *never* apply more than 3.3V to any of the other connections
 
Last edited:
I also have stupid questions, so I think this is the right thread...

The standard SD library doesn't work with the new 4-bit interface. There is SDFat Beta by Billy, then there is uSDFS mentioned in here https://forum.pjrc.com/threads/34808-K66-Beta-Test?p=106291&viewfull=1#post106291
Which one to choose? I tried SDFat Beta and it seems to work, but anything with audio library doesn't compile with it.

Then, there is on the features list "I2S Audio Port, 4 Channel Digital Audio Input & Output". What does that actually mean? Using that still requires Audio board or equivalent, so is this any different to Teensy 3.2?
 
As far as SD library - IIRC, PJRC is looking to release ASAP a version compatible with the new Teensy 3.5/3.6 SDIO hardware.
 
As far as SD library - IIRC, PJRC is looking to release ASAP a version compatible with the new Teensy 3.5/3.6 SDIO hardware.
Good to know. I'm sure it will be available before I'll have the time to really build something on the 3.6. In the mean time, the SD adapter on Audio board still works with the 3.6, with the old library!

I'm curious, what is on Paul's todo-list right now? First the software work, then the documentation, or? Is a Wiki site planned?
 
A Wiki is among the known plans - but expected after software and some primary PJRC site/docs and perhaps FORUM change. Paul made some post in recent weeks of some detail - but in general terms as none of the tasks are finite - or always under his control - like new IDE versions - or found issues.

Here was the last post I saw about functional SD on the new boards: microSD-slot-on-teensy-3-6?
 
I also have stupid questions, so I think this is the right thread...

The standard SD library doesn't work with the new 4-bit interface. There is SDFat Beta by Billy, then there is uSDFS mentioned in here https://forum.pjrc.com/threads/34808-K66-Beta-Test?p=106291&viewfull=1#post106291
Which one to choose? I tried SDFat Beta and it seems to work, but anything with audio library doesn't compile with it.

Then, there is on the features list "I2S Audio Port, 4 Channel Digital Audio Input & Output". What does that actually mean? Using that still requires Audio board or equivalent, so is this any different to Teensy 3.2?

concerning SD library:
Up to now only uSDFS supports exFAT ( native >32 GB)- but uSDFS works only with T3.5/T3.6.
( I only made a quick port for my own (exFAT) applications and made it available on GitHub)
so Bill's SDFat is a good choice.

4-chan I2S was available also for T3.2 and does not need PJRC Audio board, E.g you could attach 4 I2S microphones from onehorse (pesky @ tindy)
 
I may be interested in seeing the code you are using

@WMXZ: Sorry for a wrong impression - by "another way" I had meant to say "another way to Bill Greiman's SDFat". This is, of course, your very own "https://github.com/WMXZ-EU/uSDFS". The link I referenced in my post leads to the help given from Manitou which pointed me at your zip file.

However, perhaps it is still worth posting a code example for Noobs (like myself) to see just how EASY this is.

I claim no originality :) ... All I have done is to tease out the steps involved manually via the SERIAL MONITOR (taken from your own zip file example) so that I could (a) open or close a file for writing, (b) write any byte of my choosing, (c) vary the number of bytes written.

The example has no error handling, so anyone following it must take care to enter what the code is expecting from the SERIAL MONITOR (and in the correct sequence). Always close a file when done with writing. Format the SD card first on a PC as normal.

---

First, the uSDFS library needs to be "Included" in the Arduino IDE - as per WMXZ's instructions in the downloaded zip file.

Instructions for this example use:
========================
1) IMPORTANT - Ensure that the formatted microSD card is inserted into the Teensy 3.6 microSD socket first. Too easy to forget to do it :) !!
Once the example code has compiled and downloaded, open the SERIAL MONITOR to use the following commands.
2) The file opened will always have the suffix ".DAT". You can name your file by typing "f" followed by the prefix name, e.g. "fTest001" gives file name = Test001.DAT.
3) Default data byte is character "A". You can change the data written to be any single ascii character using the "z" command, e.g. "zB" gives data byte = 0x42 (="B").
4) Default number of bytes to be written is "0080" (eighty decimal). You can change the number of bytes using the "d" command, e.g. "d0100" = one hundred decimal.
(always pad the number out with leading zeroes to be between "0000" and "9999").

Now you can write data to a file...

5) Type the command "o" to open the file that you named. Send.
6) Type the command "s" to store the data in the file. Send.
7) Type the command "c" to close the data in the file. Send.

When you first download the example code to the Teensy T3.6, nothing happens until the SERIAL MONITOR window is opened. At that point, you should see four blinks of the Teensy LED. This gives reassurance that the setup routine has executed and the main loop is running. You will also see four blinks if the reset button is pushed with the SERIAL MONITOR window open.

At each step 5), 6) or 7) you should see the LED blink once to indicate it has received the command. The time taken for writing the data is given in microSecs.

To inspect your file afterwards, use a hex editor (such as http://www.hexedit.com/) to open it for reading and you can then see exactly what your file contains.

My thanks to WMXZ for his excellent work. You can read more on this topic at http://elm-chan.org/fsw/ff/00index_e.html.

Code:
//TBill SD Data Logger 02 SEP 2016
//================================
//Version 1.00
//Data Logging from T3.6 to SD Card
//Thanks to WMXZ for uSDFS zip file (https://github.com/WMXZ-EU/uSDFS)

//-------------------------------------------------------------------  
//Includes and Declarations
//-------------------------------------------------------------------  
#include <stdint.h>
#include <ff.h>

#define LED_ON     GPIOC_PSOR=(1<<5)
#define LED_OFF    GPIOC_PCOR=(1<<5)
#define BUFFSIZE (16*4096) 
uint8_t buffer[BUFFSIZE] __attribute__((aligned(16)));  //8 bit data buffer = size of log file
UINT wr;
FRESULT rc;       //Result code
FATFS fatfs;      //File system object
FIL fil;          //File object
char filename[80], FileDataChar;

int Byte1, Byte2, Byte3, Byte4, Byte5, NBytes1, NBytes2, DBytes=80, LoopCount;
unsigned long time1;

//-------------------------------------------------------------------  
//Setup and Loop
//-------------------------------------------------------------------
//User setup routine
void setup() {
  //initilise variables
  PORTC_PCR5 = PORT_PCR_MUX(0x1);   //LED PC5 pin 13, config GPIO alt = 1
  GPIOC_PDDR = (1<<5);              //make this an output pin
  LED_OFF;                          //start with LED off
  FileDataChar = 'A';               //default data character
  Serial.begin(115200);
  while (!Serial);
  sprintf(filename,"AAAAAA.DAT");   //default filename
  Serial.print("Filename = ");Serial.println(filename);
  Serial.println("f=filename, o=open, s=store, c=close");
  Serial.println("dXXXX=Dbytes, zX=data");
  f_mount(&fatfs, (TCHAR *)L"/", 0);  //mount a logical drive
    
  //blink 4 times
  Blink();
  delay(400);
  Blink();
  delay(400);
  Blink();
  delay(400);
  Blink();
  delay(400);
} //end of User setup routine

//User loop routine
void loop() {
  //read key input (if any)
  KeyInput();                         //read key input (if any)
  LoopCount++;                        //keep tally of loop counts

} //end of User loop routine

//-------------------------------------------------------------------  
//Subroutines
//-------------------------------------------------------------------
//Blink Routine
void Blink() {
  //blink the LED
  LED_ON;
  delay(10);
  LED_OFF;
  delay(10);
} //end of Blink routine

//KeyInput Routine
void KeyInput() {
  //blink the LED
  if (Serial.available() > 0) {
    //read the incoming byte
    Byte1 = Serial.read();
    if (Byte1>0x60) {
      switch (Byte1) {
      case 0x6F:  //o - Open File
        // OPEN new file
        //==============
        rc = f_open(&fil, filename, FA_WRITE | FA_CREATE_ALWAYS);
        if (rc) {
          Serial.print(filename); Serial.println(" was NOT opened"); Serial.flush();
          break;
        }
        Serial.print(filename); Serial.println(" was opened"); Serial.flush();
        Blink();
        break;
      case 0x73:  //s - Store Data from buffer in file on SD card
        // STORE data in file
        //===================
        for(int ii=0;ii<BUFFSIZE;ii++) {
          buffer[ii]=FileDataChar;
        }
        //write data to file 
        time1 = micros();
        Serial.print("Start Time = ");
        Serial.println(time1);
        rc = f_write(&fil, buffer, DBytes, &wr);
        time1 = micros();
        Serial.print("End Time = ");
        Serial.println(time1);
        if (rc) {
          Serial.println("Data was NOT written"); Serial.flush();
          break;
        }
        Serial.println("Data was written"); Serial.flush();
        Blink();
        break;
      case 0x63:  //c - Close File
        //CLOSE file
        //==========
        rc = f_close(&fil);
        if (rc) {
          Serial.print(filename); Serial.println(" was NOT closed"); Serial.flush();
          break;
        }
        Serial.print(filename); Serial.println(" was closed"); Serial.flush();
        Blink();
        break;
      case 0x66:  //f - Filename
        //CHANGE FILE name
        //================
        if (Serial.available() < 3) {
          Serial.print("Filename not specified - existing = "); Serial.println(filename); Serial.flush();
          break;
        }
        Byte2 = Serial.available();
        NBytes1 = 0;              //total bytes available
        NBytes2 = 0;              //total less illegal characters
        while (NBytes1 < Byte2) {
          Byte3 = Serial.read();
          if (Byte3 > 0x2F) {     //test for illegal characters
            filename[NBytes2] = Byte3;
            NBytes2++;
          }
          NBytes1++;
        }
        filename[NBytes2] = '.'; NBytes2++;
        filename[NBytes2] = 'D'; NBytes2++;
        filename[NBytes2] = 'A'; NBytes2++;
        filename[NBytes2] = 'T'; NBytes2++;
        filename[NBytes2] = 0;
        Serial.print("Filename is now "); Serial.println(filename); Serial.flush();
        Blink();
        break;
      case 0x7A:  //z - FileDataChar value
        //CHANGE FILE DATA character
        //==========================
        if (Serial.available() > 2) {
          Byte2 = Serial.read();
          FileDataChar = Byte2;
        }
        Serial.print("Data = ");Serial.println(FileDataChar); Serial.flush();
        Blink();
        break;
      case 0x64:  //d - Number of Data Bytes
        //change Number of Data Bytes
        if (Serial.available() > 3) {
          Byte2 = Serial.read();
          Byte3 = Serial.read();
          Byte4 = Serial.read();
          Byte5 = Serial.read();
          DBytes = ((Byte2-48)*1000) + ((Byte3-48)*100) + ((Byte4-48)*10)+(Byte5-48);
        }
        Serial.print("Num of Data Bytes = ");Serial.println(DBytes); Serial.flush();
        Blink();
        break;
      case 0xFF:  //h
        //task goes here...
        Blink();
        break;
      } //end of switch statement
     } //end of Byte1 > 0x60
  } //end of if Serial Available
} //end of KeyInput routine
 
Last edited:
However, perhaps it is still worth posting a code example for Noobs (like myself) to see just how EASY this is.

That was the main reason why I asked. Independent of the topic, the more examples are on the forum the more useful the forum is (IMHO).

BTW, I think you could use
Code:
case 's'
instead of
Code:
case 0x73
 
I'm glad this thread exists. On the card for 3.6 there are pins marked as Touch. I have looked at the capacitive sensor library and examples. Are these the pins to connect? Do they have some other special stuff I don't know about?
 
I'm glad this thread exists. On the card for 3.6 there are pins marked as Touch. I have looked at the capacitive sensor library and examples. Are these the pins to connect? Do they have some other special stuff I don't know about?

yep the yellow pins, ye just say val=touchRead(23);
value will change if you attach a jumper to the pin, touch the jumper insulation, or touch the raw wire of the jumper
 
Fantastic! Just tried it out, I didn't know it could be so easy!

Also, while I'm at it, why is there an analog ground, what is it for?
 
I expect the analog ground is to improve accuracy of the A/D conversions, and maybe DAC outputs too.

For ADC the *very* small voltage difference that may exist between digital ground and ground of analog source can easily be enough to affect the accuracy of a 10/12 bit ADC. If you wire the ground of analog source direct to teensy analog ground it can reduce ground loops, and the ADC reading error, thus improve accuracy

For example when using 3.3V and an ADC of 10 bits, each bit increment is only about 3.2mV (3.3/1024) and less than 1mV for 12 bits (3.3/4096)
 
Last edited:
Status
Not open for further replies.
Back
Top