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

Thread: Questions from a Newbe

  1. #1
    Junior Member
    Join Date
    Aug 2019
    Posts
    2

    Questions from a Newbe

    I have been learning the Teensy 3.6 and have a few questions which will show that I am new to the Teensy world!
    Is there an equivalent for the Teensy like the Language Reference for the Arduino
    https://www.arduino.cc/reference/en/
    that shows the differences from the generic Arduino and the Teensy 3.6 and 4.0?

    Like, where are the instructions and example on how to use “touchRead”? Is there a document with that information?
    True, I found information on the forum but there must be instructions I don’t know about. I just came across “digitalWriteFast()” today… What other powerful and usefulness do I not know about??

    The Arduino has “PORTB =0x00;”
    The Teensy 3.6 has “GPIOD_PDDR = 0xFBFF;”
    Neither of those work on the Teensy 4 (I totally understand “not yet implemented”)
    I need to write 12 bits out at once

    I see in the example “analogContinuousRead” that the ADC can read 16 bits at 193khz and 12 bits at 231khz. Is that only in the continuous read mode? Can I read one 16 bit word once every 10 us, do processing on that work then send it to the DAC in a 10us loop? If this is doable, are there code examples that show ADC/DAC setup and reading and writing single words?
    “ContinuousRead” seems so asynchronous and where is the data that is read stored? How is it used in that example?
    I need to read and write every 10 us – any jitter is seen as quantization noise
    In this example I see this code:
    digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN));
    to toggle the LED? How does a read turn the LED off?
    Is that faster then what Paul used in his I/O speed test

    digitalWriteFast(14, HIGH);
    digitalWriteFast(14, LOW);

    Finally, am I missing some setup on A1, A21 and A22?
    From the K66 spec:

    “ 41.1.1 12-bit DAC Overview
    This device contains two 12-bit digital-to-analog converters (DAC) with programmable
    reference generator output.”

    “39.2 Introduction
    The 16-bit analog-to-digital converter (ADC) is a successive approximation ADC
    designed for operation within an integrated microcontroller system-on-chip.”


    void setup()
    {
    pinMode(A1, INPUT);
    pinMode(21, OUTPUT);
    Serial.begin(9600);
    }
    int result;
    void loop()
    {
    result = analogRead(A1);
    Serial.print(result);
    analogWrite(A21, result);
    }

    The input read never goes over 1023 (if 16 bits it should be 0 to 64k) and anything over 255 output results in 3.3 volts output. 12 bits should give 0 to 4095 for 3.3 volts output. Why is the input limited to 10 bits and the output limited to 8 bits?

    I realize the questions show my newness.
    Thank you for your patience in answering my questions (that everybody should know!)

  2. #2
    A lot going on in your post, kinda hard to make a coherent response to it, but I suppose I'll try.

    Regarding the LED, the line of code you posted: "digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN));"

    In english this would be something like "set the output pin to the opposite of whatever it is right now".

    Regarding the speed of digitalWriteFast, I believe the performance is going to vary based on what platform (Teensy 2, 3, 4, etc) you're on. Why not attach an oscilloscope and measure it?

    Regarding the ADC resolution, you need to set the resolution, like so: analogReadRes(13). The number is the resolution in bits.

    The best way to learn what is available, what it can do, and how it works, is to dig into the core arduino implementation: https://github.com/PaulStoffregen/cores

  3. #3
    Junior Member
    Join Date
    Aug 2019
    Posts
    2
    Quote Originally Posted by wcalvert View Post
    A lot going on in your post, kinda hard to make a coherent response to it, but I suppose I'll try.

    Regarding the LED, the line of code you posted: "digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN));"

    In english this would be something like "set the output pin to the opposite of whatever it is right now".

    Regarding the speed of digitalWriteFast, I believe the performance is going to vary based on what platform (Teensy 2, 3, 4, etc) you're on. Why not attach an oscilloscope and measure it?

    Regarding the ADC resolution, you need to set the resolution, like so: analogReadRes(13). The number is the resolution in bits.

    The best way to learn what is available, what it can do, and how it works, is to dig into the core arduino implementation: https://github.com/PaulStoffregen/cores
    Ah!, yes, I saw the "!" as a NOT but thought it was funny that it was attached to a read command. I understand.
    Oh, I did hook the scope to the output. My scope is not fast enough or cables too long but if I coded what Paul did, it appears I get no output- I do get a 20ns pulse if I turn off the slew rate limit.

    Set resolution!! THAT's what I was missing! (one of those commands I do not know about!) Thank you! I will give that a try!

Posting Permissions

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