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

Thread: Using Adafruit_MCP3008.h library causes pin 13 LED to light up

  1. #1
    Junior Member
    Join Date
    Oct 2020
    Location
    Melbourne, Australia
    Posts
    12

    Using Adafruit_MCP3008.h library causes pin 13 LED to light up

    Hi there,
    I'm using a Teensy 4.1 connected to an MCP3008 via SPI where pin 13 is the SCK.
    I'm using the Adafruit_MCP3008.h library to interface with the ADC, however I'm getting a weird problem on some of my boards but not others: when I start the SPI with adc.begin(), the LED attached to pin 13 on my Teensy will light up. This is occurring on 3 out of 5 of my boards. The ADC seems to be functioning just fine and I am getting readings with adc.readADC(). However I don't want the LED to light up because it will drain the battery.
    If I reflash with Blink firmware then the LED flashes normally.
    Does anyone have any idea what might be causing this?
    Thanks.

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,345
    You haven't posted your code.

    Can you confirm the boards are identical, programmed identically? Normally the quiescent SCLK will be determined by the
    SPI mode in use.

    Are you expecting the tiny LED on the pcb to consume significant power compared to the rest of the T4.1?

  3. #3
    Junior Member
    Join Date
    Oct 2020
    Location
    Melbourne, Australia
    Posts
    12
    Thanks Mark,

    The code is over 500 lines and proprietary, but I have found that commenting out the adc.begin() stops the LED turning on. I can also turn the light off by manually setting pin 13 LOW (which breaks SPI, obviously).

    From this standpoint, I'm just wondering is it normal for the SCK signal to light up the LED? And if so, why is it happening on some of my boards and not others?

    This thread seems to indicate that it is normal, with the SCK behaving somewhat like a PWM.

    The boards are identical copies from the same PCBway run, each with its own Teensy soldered on, programmed identically. The LED will consume some power and it's a battery powered application, so I would prefer it off. But far more importantly, I just really need to understand what's going on here. Is this normal?

  4. #4
    Senior Member
    Join Date
    Nov 2015
    Location
    Cold hollow VT
    Posts
    204
    According to the schematic at https://www.pjrc.com/teensy/schematic.html the LED is in series with a 470 ohm resistor. Get your clippers and pick one to snip.

  5. #5
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,345
    If the boards are identical and programmed identically I would expect the LEDs to light identically.
    Yes the pin drives the LED so it will light up when there's activity. LEDs light up in nanoseconds, no
    problem following a logic signal. Its possible different LEDs might have different turn-off delays
    perhaps that explains a difference in brightness?

    You know the Teensy 4 pulls a lot of current, will dwarf the LED few mA I suspect.

  6. #6
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    454
    You know the Teensy 4 pulls a lot of current, will dwarf the LED few mA I suspect.
    About 4mA.

  7. #7
    Junior Member
    Join Date
    Oct 2020
    Location
    Melbourne, Australia
    Posts
    12
    Thanks all. Looks like this is normal behaviour

  8. #8
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,097
    Quote Originally Posted by JeremiahRose View Post
    Thanks all. Looks like this is normal behaviour
    This is due to the Teensy using the same pins for Arduino UNO, which had the SPI clock pin (13) on the same pin as the LED. The first Serial port (pins 0/1) and the I2C bus (18/A4 and 19/A5) are also the same. Having the clock pin be the same as the LED, doesn't interfere with SPI transfers, but it does cause the LED to blink rapidly.

Posting Permissions

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