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

Thread: T-LC Hardwear DAC and LED

  1. #1
    Junior Member
    Join Date
    Apr 2017
    Location
    at home
    Posts
    11

    T-LC Hardwear DAC and LED

    At the movement I'm not interested in Forth coded Automatic Video Cuckoo Clock, I would just like to use the in board LED on "PIN 13" AND the hardware DAC at the same time - BUT they SEEM to use the same pin ? HUH? I'm confused - If they do 'share' the Pin, then how do I disconnect the LED from the PIN so I can use the analog output AND how do I then flash the led. I have looked all over and there is a lot of esoterica but little simple stuff. (started out with 6800 @ 1 Mhz with 16 bytes of ram and 512 bytes of EPROM.).
    Last edited by emmbeabee; 04-01-2019 at 07:14 PM. Reason: 2--3

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,453
    The LED is on digital pin13, the DAC output is analog pin A12 on Teensy LC. Thus different pins, no conflict.

  3. #3
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,021
    Indeed - the card image shows those two pins are side by side but they are independent pins:
    pjrc.com/teensy/teensyLC.html#pinout

  4. #4
    Junior Member
    Join Date
    Apr 2017
    Location
    at home
    Posts
    11
    Quote Originally Posted by defragster View Post
    Indeed - the card image shows those two pins are side by side but they are independent pins:
    pjrc.com/teensy/teensyLC.html#pinout
    & Theremingenieur
    Ah Umm I could claim that the card was creased so it was partially illegible - but it is most likely terminal brain failure - sorry & thanks for the soft letdown. Mike

  5. #5
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,063
    Note there are places where there are overlaps. For example, the built-in LED is on pin 13, and the default SPI SCLK pin is also on pin 13. In this case it doesn't matter, in that SCLK is an output only pin, so it would cause high speed blinking if you use a SPI device like a monitor. It might be a potential issue if you try to read from pin 13, since the resistor used for the LED can bias the input values.

  6. #6
    Junior Member
    Join Date
    Apr 2017
    Location
    at home
    Posts
    11

    Smile

    Quote Originally Posted by MichaelMeissner View Post
    Note there are places where there are overlaps. For example, the built-in LED is on pin 13, and the default SPI SCLK pin is also on pin 13. In this case it doesn't matter, in that SCLK is an output only pin, so it would cause high speed blinking if you use a SPI device like a monitor. It might be a potential issue if you try to read from pin 13, since the resistor used for the LED can bias the input values.
    AH-HA You have hit the nail right on the head - with a club hammer - I was also wondering about that and got my poor old brain in a complete taffle - mixing the two "I wonder how it works" up together. humm - could you point me to some text or descriptio how the various pin mode switches are done ? Auto-Magically ? or do I have to trigger macros - somehow.
    Thanks 3 you all.
    Mike

  7. #7
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,021
    This came up a bit differently last couple of days - this reply from Paul points the way a bit … this post and the ones prior set the stage …

    Secondary-Ports-T3-5\

    Quote Originally Posted by PaulStoffregen View Post
    They do indeed, and those functions are documented on the pages for those libraries.

    With SPI, the CS pins are normally controlled with digitalWrite() or digitalWriteFast().

  8. #8
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,063
    Quote Originally Posted by emmbeabee View Post
    AH-HA You have hit the nail right on the head - with a club hammer - I was also wondering about that and got my poor old brain in a complete taffle - mixing the two "I wonder how it works" up together. humm - could you point me to some text or descriptio how the various pin mode switches are done ? Auto-Magically ? or do I have to trigger macros - somehow.
    Thanks 3 you all.
    Mike
    Well to see how it really works, you have to do a deep dive into the library sources and also read the processor manual for the particular processor involved.

    In general, each pin has several modes that it can be in, and when you use the library function for a particular library and/or use the pinMode function, it sets the mode automatically. In the case of alternate pins, you have to call a function to set that you are using an alternate pin.

    Usually you don't have to worry about doing the switch, as it happens behind the scenes. Sometimes you do. For example, I have this script (uncannyEyes) that was written by somebody at Adafruit to rapidly draw two eyes on two 128x128 bit displays. I wanted to add ws2812b (neopixel) support because it wasn't gaudy enough, and I used the prop shield to do level shifting for the ws2812b LEDs. The prop shield uses the SPI pins (11, 13), and it has another pin that says do the level shifting. When I add the LEDs, I have to manually stop those pins from being in SPI mode, and put them into normal mode, and then reverse the process after the LEDs are emitted so I could use SPI to write to the screens (note, somebody else did the deep dive to figure out how to reset the pins).

    For displays it becomes more complicated, since some of the libraries have optimizations that they will do the SPI writes in the background using DMA, and when you are switching, you have to wait until the DMA requests have all been handled.

    On the SPI bus, you can have multiple devices on the bus, each device has a CS (chip select) pin, and when the pin is set to a certain state, the device will look for commands. If the CS pin is not in that state, the device will ignore the SPI commands. The Prop Shield that I mentioned uses pin 7 to enable voltage translation on pins 11/13, and pin 6 to enable reading/writing the flash memory chip in the prop shield. If neither pin 6 or 7 are set, the prop shield doesn't use pins 11 and 13. In terms of SPI, there are some devices that don't play nicely with other devices on the bus (and there are ways to deal with this).

    The I2C bus is slightly different in that instead of a separate CS pin for each device, each device has an address, and the device will only talk to the master on requests where the address is the one specified in the request.

    On the SPI bus, if you randomly turn the LED on/off, it may interfere with other SPI devices that you might be using.

    BTW, some of the overlap pins such as the pin 13 being used for the SPI clock and for the LED was first used in the Arduino Uno and the Teensy just copied those pin assignments.

  9. #9
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Aline26, which pin is between 3.3v and vin?

  10. #10
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,021
    Quote Originally Posted by Frank B View Post
    Aline26, which pin is between 3.3v and vin?
    Spammer Busted - by FrankB

Posting Permissions

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