Code does not run after power-on-reset (Teensy 3.0)

Status
Not open for further replies.

jlewis184

Member
I'm having a problem where my code does not run after a power-on-reset (POR). Once I re-flash the device, the software runs smoothly.

I'm using external power and have cut the VIN trace from VUSB.

What could cause this behavior and what can I do to fix this?

-Josh
 
Sorry to bump, but my project is dead in the water if I have to re-flash the device on each power up. Has anyone experienced a problem similar to this?
 
Do you have anything like "while (!Serial) ;" in your code? That's usually the most common problem with startup issues.

If not, perhaps post a followup after reviewing these guidelines. With more info, you might get a useful answer.
 
Sorry for not attaching the code. I was thought this might be a hardware issue...

Code:
/*  OctoWS2811 BasicTest.ino - Basic RGB LED Test
 http://www.pjrc.com/teensy/td_libs_OctoWS2811.html
 Copyright (c) 2013 Paul Stoffregen, PJRC.COM, LLC
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:
 
 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 
 Required Connections
 --------------------
 pin 2:  LED Strip #1    OctoWS2811 drives 8 LED Strips.
 pin 14: LED strip #2    All 8 are the same length.
 pin 7:  LED strip #3
 pin 8:  LED strip #4    A 100 ohm resistor should used
 pin 6:  LED strip #5    between each Teensy pin and the
 pin 20: LED strip #6    wire to the LED strip, to minimize
 pin 21: LED strip #7    high frequency ringining & noise.
 pin 5:  LED strip #8
 pin 15 & 16 - Connect together, but do not use
 pin 17: Analog Input A3 - CH#1
 pin 4 - Do not use
 pin 3 - Do not use as PWM.  Normal use is ok.
 
 This test is useful for checking if your LED strips work, and which
 color config (WS2811_RGB, WS2811_GRB, etc) they require.
 */

#include <OctoWS2811.h>

const int ledsPerStrip = 30;
const int ledPin = 13;
int count = 0;
char state = 0;
int PositionAvg = 0;
int PositionInt = 0;
int darkness = 0;

int Red;
int Green;
int Blue;
int Position;
int Width;
int previousPosition = 0;
int previousWidth = 0;
int previousLength = 0;
int Darkness;
int Length;

uint32_t color = 0;
uint32_t colorADC = 0;
uint32_t colorRGB = 0;

uint32_t bitColor[16] = {
  0xFFFFFF, 0xC0C0C0, 0x808080, 0x000000,
  0xFF0000, 0x800000, 0xFFFF00, 0x808000,
  0x00FF00, 0x008000, 0x00FFFF, 0x008080,
  0x0000FF, 0x000080, 0xFF00FF, 0x800080};

int bitColorR[16] = { 
  0xFF, 0xC0, 0x80, 0x00, 0xFF, 0x80, 0xFF, 0x80,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80};                      
int bitColorG[16] = { 
  0xFF, 0xC0, 0x80, 0x00, 0x00, 0x00, 0xFF, 0x80,
  0xFF, 0x80, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00};
int bitColorB[16] = { 
  0xFF, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x80};

DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];

const int config = WS2811_GRB | WS2811_800kHz;

OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);

void setup() {
  pinMode(ledPin, OUTPUT);
  leds.begin();
  leds.show();
  Serial.begin(9600); // USB is always 12 Mbit/sec 
}

void loop() {

  readADC();
  printADC();
  toggleLED();

  for (int i=0; i < previousWidth; i++)leds.setPixel(previousPosition+(previousLength*i), 0);
  for (int i=0; i < Width; i++)leds.setPixel(Position+(Length*i), Red, Green, Blue);  
  leds.show();
  previousPosition = Position;
  previousWidth = Width;
  previousLength = Length;
}

void toggleLED(){
  if(count++>=120){
    count=0;     
    if(state){
      digitalWrite(ledPin,state);
      state=!state;
    }
    else{
      digitalWrite(ledPin,state);
      state=!state;
    }
  }
}
void readADC(){
  Position = (analogRead(A3)>>2);
  Width = analogRead(A5)>>2;
  if(!Width)Width=1;
  Length = analogRead(A9)>>4;
  if(!Length)Length=1;
  Red = analogRead(A4)>>2;
  Green = analogRead(A8)>>2;
  if(Green<220 && Green>=25)Green-=25;
  Blue = analogRead(A10)>>2;
  if(Blue>0)Blue-=1;
}
void printADC(){
  Serial.print("Position:"); 
  Serial.print(Position);
  Serial.print(", Width:"); 
  Serial.print(Width);
  Serial.print(", Length:"); 
  Serial.print(Length);
  Serial.print(", Red:"); 
  Serial.print(Red);
  Serial.print(", Green:"); 
  Serial.print(Green);
  Serial.print(", Blue:"); 
  Serial.println(Blue);

}
 
How are you doing the power-on-reset?

The reason I ask is because the button on the teensy itself is not a "reset power" button - it reboots the teensy into "reprogramming mode". In that mode, the teensy will sit there waiting for new code to be uploaded to it. This button is not what you want to use to reboot the teensy and run your own code. A lot of people have previously misunderstood this, and tried to use this button to reboot - and then wondered why it wasn't running their code afterwards.

If that's not what's happening, it's beyond my knowledge - I just thought it worth checking the simple case first ;).
 
Dawnmist, thanks for your response.
The Teensy is powered via a 5VDC wall-wart and this 50W supply is also powering a LED pixel strip. The POR event occurs when I plug in the power supply.

What I find strange is even though the chip powers up in frozen state, if I attach the USB cable and reprogram everything runs smooth. When I remove the USB after the chip is running, everything is still good. But when the power is cycled, the chip freezes (the "heartbeat" stops blinking).

Paul, I've been testing with "Blink" example code since you alerted me to the possibility of the software hanging.

I've removed all my application's supporting circuitry to no avail.
 
I have tried multiple 5V power supplies and have scoped the 5V rail. It's stable and clean, but this behavior persists.

One thing I've noticed with this particular Teensy 3.0 is that after it's powered up, I can only connect to the Teensy bootloader after pressing the button on the board. My other Teensy 3.0's can be hot-plugged and connect first try. This could be a clue?

Regards
 
An update....I replaced the Teensy with another and now it too is having problems starting up. I have to power cycle over and over, and the Teensy will come up about 1 out of 10 times.
 
Any chance I can get that particular power supply? I'd love to have it here for testing! I'd be happy to ship you one of mine that works fine.
 
An update....I replaced the Teensy with another and now it too is having problems starting up. I have to power cycle over and over, and the Teensy will come up about 1 out of 10 times.
If you turn on the power supply and its LED load, then wait a second before applying its power to the Teensy, does the teensy startup properly? This checks if the Teensy is or is not able to cope with a slow voltage ramp-up.
 
Last edited:
Any chance I can get that particular power supply? I'd love to have it here for testing! I'd be happy to ship you one of mine that works fine.

I have been mostly using this supply from Adafruit. But I've recently purchased 8 more "desktop" style supplies, from the Chinese supplier where I sourced my LED strips.

I'd be happy to send you one of these supplies to test with, but this fault happens when I've experimented with multiple 5V sources, including my bench supply.

I'll capture power on waveforms of VREGIN and VDD when I get the chance.
 
Status
Not open for further replies.
Back
Top