Teensy 4.1 Problem setting output pin before its declaration

Scope signals with my Gate circuit..
The gate pin on the 74HC595 is faster high and 74HC595 outputs off. When switched power on, all LEDs are off :)

RigolDS4.png


Circuit_74hc595.png
 
Last edited:
That delay would likely be the USB initialization. There is information about how to reduce this / using the startup hooks to initialize hardware earlier than in startup() on this page: https://www.pjrc.com/teensy/td_startup.html

(But, I'm not sure why a physical pull-up on the Teensy's output pin wouldn't be sufficient; in fact it looks exactly like that is what you're using for the transistor's gate.)
 
But there's still time left for the Teensy MCU's reset phase. A few milliseconds, I estimate. The outputs aren't defined :unsure:
 
Did you think to try something stronger like 1k? Or even some network from 5V rail that pulls up to 3.3V independently of the actual processor 3.3V rail? So 1k to 5V and 2k to ground perhaps, being the Thevenin equivalent of 660R to 3V3?
 
C-like:
pinMode(29, INPUT_PULLUP);
pinMode(29, OUTPUT);
digitalWriteFast(29, HIGH);

4.7K and I also tried different pins on the Teensy and always tested in connection to the gate input of the 74HC595.

Measured here with 4.7K pullup on the Teensy pin without connection to 74HC595.
RigolDS6.png


Measured here with 1K pullup on the Teensy pin without connection to 74HC595.
RigolDS7.png


Measured here with 680R pullup on the Teensy pin without connection to 74HC595.
RigolDS8.png
 
Last edited:
Init the light shown on my Synth project..
There are 24 status LEDs in different colors for the 24 keys. These are controlled by three 74HC595 slide switches. For some keys, the LEDs are not yet wired.

 
Last edited:
But there's still time left for the Teensy MCU's reset phase. A few milliseconds, I estimate. The outputs aren't defined :unsure:
At power-up the default pin state is input / tri-state / high impedance so an external pull-up should be fine.
There's definitely something fishy about those scope shots; there is no explanation for the voltage being around 1.2V no matter what state the pin is in, assuming there is nothing besides a pull-up resistor connected.
 
I can't explain it either. The pull-up resistor is connected to a separate 3.3 volt line. Perhaps that's the cause. I supply the entire circuit with +12V. The Teensy is supplied with +5V via a switching regulator. I generate the +3.3V using a fixed-voltage converter (see image).

Netzteil 5.0_3.3.png
 
Mmmm :unsure:

I've now used a Teensy4.0 board and am getting different results. Since the Teensy4.0 doesn't have pin 29, I used a different pin 2 with an external 4.7K pull-up connected to +3.3V from the Teensy. The signal is almost identical to the 3.3V supply voltage. The signal curve is correct as in theory and in practice :)

But what's wrong with Teensy4.1? I'll check it again..


RigolDS9.png
 
As I suspected, it's the power supply. My test power supply delivers a stable 5V supply voltage immediately after switching off from standby. The voltage regulator on my DIY board takes a few milliseconds to adjust the voltage from +12V to +5V. When switched on, the GPIO in the Teensy4.1 behaves unstable.
 
It's clearly due to my power supply in the DIY project.
1st image shows a 4.7K pull-up on Teensy4.1 pin 29 with +5V and +3.3V from the Teensy.
2nd image shows a 4.7K pull-up on Teensy4.1 pin 29 with +5V and +3.3V from the DIY project's power supply.

1.Pic +5V and +3.3V from Teensy4.1 Board
RigolDS0.png


2.Pic +5V and +3.3V from DIY Projekt power supply
RigolDS1.png


DIY Projekt power supply
Netzteil 5.0_3.3.png



Voltage curve on the DIY power supply
RigolDS2.png
 
Last edited:
You could try tying just the pull-up for the gate input of the 74HC595 to the Teensy's 3.3v regulator. The rest of your circuit can continue to use the your 3.3v supply.
 
Yes it clearly won't help as the pullup has to be to 595's supply so its there when the 595 power up, and yet not be hindered by the T4 being unpowered... I think you're right a transistor or opto-coupler is needed.
 
Ok. I think it's the problem comes from the +3.3V supply voltage from Teensy Board. The Teensy gets its +5V supply voltage on pin Vin (yellow curve). After 15ms, the TLV75733P chip on the Teensy switches on the +3.3V supply voltage on the 3.3V Pin (blue curve).

Info: The +5V supply voltage for the Teensy Board comes from my laboratory power supply and is switched on via the ON/Off function buttons.

Teensy4.1_Board.png



RigolDS0.png
 
Last edited:
My Led panel..
Degenerator2_LED_Panel.png

My Teensy code..
C:
// LED driver
// Pin connected to ST_CP of 74HC595
int latchPin = 30;
// Pin connected to SH_CP of 74HC595
int clockPin = 31;
// Pin connected to DS of 74HC595
int dataPin = 32;
// Pin connected to OE of 74HC595
int oePin = 29;

// Setup -------------------------------------------------------
void setup()
{
    // init LED driver 74HC595
    // During initialization, the OE pin on the 74HC595 has
    // high level via a transistor inverter
    pinMode(latchPin, OUTPUT);
    pinMode(clockPin, OUTPUT);
    pinMode(dataPin, OUTPUT);
    pinMode(oePin, OUTPUT);
    digitalWrite(oePin, LOW);
   

// set LED Status ----------------------------------------------
void set_LED_Status()
{
    if (update_LED_Status_Timer >= 170)
    {
        update_LED_Status_Timer = 0;
        static uint32_t data = 1;          

        for (int numberToDisplay = 0; numberToDisplay < 3; numberToDisplay++) {
            // take the latchPin low so
            // the LEDs don't change while you're sending in bits:
            digitalWrite(latchPin, LOW);
            // shift out highbyte
            shiftOut(dataPin, clockPin, MSBFIRST, (data >> 16));
            // shift out middelbyte
            shiftOut(dataPin, clockPin, MSBFIRST, (data >> 8));
            // shift out lowbyte
            shiftOut(dataPin, clockPin, MSBFIRST, data);
            //take the latch pin high so the LEDs will light up:
            digitalWrite(latchPin, HIGH);
            }

            // shift one bit right and turn on one of 24 LEDs
            digitalWrite(oePin, HIGH);  
            data = data << 1;
            if (data == 0)
            {
                data = 1;
            }  
    }
}

 
Last edited:
Back
Top