Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: is 2 Mbaud supported on T_3.6 at 24 Mhz

  1. #1
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,743

    is 2 Mbaud supported on T_3.6 at 24 Mhz

    I have two Teensy's connected Serial1 [ T_3.6 ] to Serial1 [ T_3.0 ] and they work at 2,000,000 baud when running at 48, 180 or 240 MHz.

    When I compile at 24 MHz on the T_3.6 with the T_3.0 code unchanged - the T_3.0 acting as PROXY to a second USB (for Serial1 debug) it no longer gets valid data.

    Is 2 Mbaud mathematically possible on T_3.6 at 24 MHz? Or is there a problem in the core math?

    Here is a Sketch to output Serial1 data at 2Mbaud that works at 48 MHz on T_3.6 (compiled Fastest with TD_1.41b4) , but shows USB garbage through PROXY Teensy:
    Code:
    #define PROXY_SER Serial1 
    #define PROXY_BAUD 2000000
    void yield() {}; // Void yield() to bypass default PJRC yield overhead
    
    void setup() {
      // serial to display data
      PROXY_SER.begin( PROXY_BAUD );
      Serial.begin(115200);
      PROXY_SER.println("\n"__FILE__" "__DATE__" "__TIME__);
      Serial.println("\n"__FILE__" "__DATE__" "__TIME__);
      pinMode(LED_BUILTIN, OUTPUT);
      while (!Serial && millis() < 4000 );
    }
    
    elapsedMillis foo;
    void loop() {
      if ( foo >= 1000) {
        PROXY_SER.println( micros() );
        Serial.println( micros() );
        foo -= 1000;
      }
    }
    Here is what I see for 'garbage' in TyComm - the micros printed are at 48 MHz - then garbage when recompiled at 24 MHz:
    19400002
    20400002
    21400002
    4���ۄ������4�D�tG���
    SerMon version of the garbage is this: "⸮⸮⸮4⸮⸮⸮⸮⸮⸮⸮⸮۴G۴G8⸮۴G۴G⸮G۴G۴G;⸮۴G۴GGG۴G۴G<⸮⸮⸮⸮⸮⸮⸮⸮ ⸮⸮⸮⸮⸮⸮"

    If I had a logic analyzer I'd hook that up to see what is happening.
    The PROXY code in use { I posted here } it is this:
    Code:
    #define PROXY_SER Serial1
    #define PROXY_BAUD 2000000
    void yield() {}; // Void yield() to bypass default PJRC yield overhead
    
    void setup() {
      Serial.begin(9600);
      while (!Serial && millis() < 4000 );
      PROXY_SER.begin( PROXY_BAUD );
    }
    
    void loop() {
      char inChar;
      if ( Serial.available() )
        PROXY_SER.print( inChar = Serial.read() );
      if ( PROXY_SER.available() )
        Serial.print( inChar = PROXY_SER.read() );
    }
    Last edited by defragster; 01-25-2018 at 07:21 AM.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,583
    Quote Originally Posted by defragster View Post
    Is 2 Mbaud mathematically possible on T_3.6 at 24 MHz?
    Nope, not possible on Serial1. 1.5 Mbps is the max when running at 24 MHz.

    More specifically, the max baud rate is F_CPU/16 on Serial1 & Serial2, and F_BUS/16 on Serial3-Serial5.

    However, Serial6 on Teensy 3.6 (and Serial1 on Teensy LC) has a special hardware feature to configure the UART's oversampling ratio. I believe Serial6 can give you 1.5 Mbps, but I haven't personally tested this.

  3. #3
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,743
    Good info, Thanks Paul.

    Just incidental - rather than monitoring free CPU time for the linked Kalman filter work - I decided just to drop the speed to see it work, and set up the debug Serial to work around a JAVA app plotting data on USB.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •