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

Thread: teensy 2.0 and teensy 3.0 question

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    7

    teensy 2.0 and teensy 3.0 question

    Hello, was wondering is there any way to make the Teensy load the code it has on it upon boot?

    I find that when i turn the power on my script does not run. I know this because my LCD's are not showing anything when they should be. If i plug the usb in and hit reboot on the teensyloader program, it then works.

    I know Teensy 3.0 has a pin i can just trigger to do this but the Teensy 2.0 does not from what i read.

  2. #2
    This is not the behavior I see. I see that when I plugin the teensy my code runs. I suspect something else is going on. Maybe some timing thing? Can you blink the LED or something to verify that your code is running?

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,169
    Teensy always runs your program when it powers up.

    Perhaps your code has something that depends on the PC responding? Could your post your code, or a small/simple program which demonstrates the problem? Also, it matter which option you've selected from Tools > USB Type, which isn't in your message, so please let us know that too?

  4. #4
    Junior Member
    Join Date
    Nov 2012
    Posts
    7
    The code on my teensy 2.0 is as follows

    HardwareSerial Uart = HardwareSerial();

    void setup()
    {
    Uart.begin(9600);
    }

    void loop()
    {
    shiftLeft();
    }

    void shiftLeft()
    {
    Uart.print("Welcome to Centennial College - ICET");
    while(1)
    {
    Uart.write(0xFE);
    Uart.write(0x55);
    delay(350);
    }
    }

    As for tools > USB Type is set as serial

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,169
    I'm running it right now on a Teensy 2.0, powered from a 5V power supply (no USB connection). It's sending those 2 bytes on pin 8 every 350 ms.

    I've switched the power off and back on several times. Every time it starts up and sends those bytes.

  6. #6
    Junior Member
    Join Date
    Nov 2012
    Posts
    7
    Quote Originally Posted by PaulStoffregen View Post
    I'm running it right now on a Teensy 2.0, powered from a 5V power supply (no USB connection). It's sending those 2 bytes on pin 8 every 350 ms.

    I've switched the power off and back on several times. Every time it starts up and sends those bytes.
    My exact setup has an LCD connected to the TX pin and it turns on at the same time with the Teensy 2.0 using the same power supply.

    Any ideas what could be wrong?

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,169
    I have no idea.

    As a first step, you might change your code to something like this:

    Code:
    pinMode(11, OUTPUT);
    while(1) {
      digitalWrite(11, HIGH);  // LED on
      Uart.write(0xFE);
      Uart.write(0x55);
      delay(350);
      digitalWrite(11, LOW);  // LED off
      Uart.write(0xFE);
      Uart.write(0x55);
      delay(350);
    }
    Then you'll at least be able to see if the LED changes, to know if your program is running.

    Maybe the LCD isn't starting up properly?
    Last edited by PaulStoffregen; 12-04-2012 at 12:16 AM.

  8. #8
    Junior Member
    Join Date
    Nov 2012
    Posts
    7
    Quote Originally Posted by PaulStoffregen View Post
    I have no idea.

    As a first step, you might change your code to something like this:

    Code:
    pinMode(11, OUTPUT);
    while(1) {
      digitalWrite(11, HIGH);  // LED on
      Uart.write(0xFE);
      Uart.write(0x55);
      delay(350);
      digitalWrite(11, LOW);  // LED off
      Uart.write(0xFE);
      Uart.write(0x55);
      delay(350);
    }
    Then you'll at least be able to see if the LED changes, to know if your program is running.

    Maybe the LCD isn't starting up properly?
    Thanks Paul, that worked and i just modified my code a bit further. By adding a delay to the actual start of the code that allowed the LCD to start fully and then start the code.

    My code now looks like

    Code:
    HardwareSerial Uart = HardwareSerial();
    void setup()
    {
      Uart.begin(9600);
      pinMode(11, OUTPUT);
      delay(100);
    }
    
    void loop()
    {
      shiftLeft();
    }
    
    void shiftLeft()
    {
      Uart.print("Welcome to Centennial College - ICET");
      while(1) {
        digitalWrite(11, HIGH);  // LED on
        Uart.write(0xFE);
        Uart.write(0x55);
        delay(350);
        digitalWrite(11, LOW);  // LED off
        Uart.write(0xFE);
        Uart.write(0x55);
        delay(350);
      }
    }
    Just incase anyone was wondering.

    Thanks again for the help!

Posting Permissions

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