Pulling pin immediately low.

Status
Not open for further replies.

Leakus

New member
I have externally an IC connected to my Teensy 3.2 which i would like to disable on startup. I have to pull a reset pin on the IC towards ground. However it takes the teensy about 100ms to do this. Is there a way to make this quicker something like 10ms wouldn't be a problem.

This is my code:

Code:
#include <Arduino.h>
const int Pin_Reset = 14; 

void setup() { 
  pinMode(Pin_Reset, OUTPUT);
  digitalWriteFast(Pin_Reset, LOW); // 100ms have passed until this happens !!
  ...

I checked how quickly the linear regulator has the 3.3V and that only takes 3 ms or so, so the delay does not result from a slow power supply.
 
Last edited:
Warning, I am a Software person, so maybe an EE type might give you a better answer.

Things I would probably try to see if it works include:

a) Tie the Reset line of the display to reset pin of Teensy? I have done this for a display to make sure the display resets without tying up an IO pin...

b) Use a weak external Pull Down resistor on the reset line, such that the pin will have a low value at startup until your code actually sets it high.
 
no need to write it low, its low by default when set by pinmode to output, maybe try putting volatile asm "dsb" after pinmode?

EDIT, a resistor like kurt said is recommended, as the pins are in high-Z whenever teensy is off, rebooted, or reprogrammed
 
As said, a resistor would do it.
If you don't want it: Take a look at the startup hooks, in startup.c, esp. the early hook.

Teensy delays the booting, because PCs are not quick enough to detect the new USB-Device, and some I2C chips need a long time, too.
 
As said, a resistor would do it.

I didn't really get it to work with a resistor. Because of the teensy's internal pullup. So I decided to put an RC in the supply of the IC to delay the startup. This works, but seems a little bit of a hack. But I'll probably leave it at that for now.
 
As Frank B noted ... and I located and tested in beta ...

Adding code in the sketch ::
Code:
int pList[] = { 0, 1, 6, 7, 2, 3, 4, 5 };
[B]uint32_t timeSEH = 0;
extern "C" void startup_early_hook(void) {
  timeSEH = micros();
  pinMode( LED_BUILTIN, OUTPUT );
  digitalWriteFast( LED_BUILTIN, 1 );
  // pin change and set code here
}
[/B]
void setup()
{
  for ( int ii = 0; ii < 4; ii++ ) {
    pinMode( pList[ii], INPUT_PULLUP );
  }
  for ( int ii = 4; ii < 8; ii++ ) {
    pinMode( pList[ii], OUTPUT );
  }
  while (!Serial && millis() < 2000) ; // wait
  Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
[B]  Serial.printf( "startup_early_hook entered at %lu us\n", timeSEH );
[/B]}

void loop() {
  for ( int ii = 0; ii < 4; ii++ ) {
    digitalWriteFast(pList[ii + 4], digitalReadFast(pList[ii]));
  }
}

Will happen in under 20 ms. I/O is ready and the systick and cycle counter is running - so millis() and micros() are valid.

On a T_4.0 here this logged timeSEH at::
Code:
T:\tCode\TEST_IO\TEST_IO.ino Jun  2 2020 03:16:17
startup_early_hook entered at 1391 us

Tested in above sketch that was currently open - run as is to test - or integrate the BOLD to test.
That was the longest time I saw on a few tries. Not the Teensy is POWERED some short time doing setup ( code copy from FLASH, CPU set to compile speed, other hardware ) before those clocks are valid.
If you have a scope you can see if that is good enough - it could be done sooner hacking startup.c::ResetHandler() >> // pin 13 - if startup crashes, use this to turn on the LED early for troubleshooting
 
Status
Not open for further replies.
Back
Top