weirdocollector
Member
Hi everybody,
I've just starting learning to use my Teensy 2.0++, and I've stumbled in something that appears to be very strange for a total noob like me.
I've written and run the following simple code that counts from 0x0000 to 0xFFFF, and sends the value in hex notation to the serial port.
------------
word i;
void setup(){
Serial.begin(9600);
Serial.println("Start counting !");
for (i = 0; i <= 0xFFFF; i++) {
Serial.println(i,HEX);
if (i == 0xFFFF) {
Serial.println("FFFF reached !");
}
}
Serial.println("Count finished!");
}
void loop()
{
}
------------
Looking at the serial monitor in the Arduino IDE, when I run this code, the setup() routine, that I thought would be run only once, is instead executed repeatedly, and the line that prints "Count finished!" is never executed, and appears to be always skipped.
Why is that ?
It looks like the Teensy is being reset at the end of the for loop.
How can I make the program do something after the first for loop ?
Thanks in advance for any help.
I've just starting learning to use my Teensy 2.0++, and I've stumbled in something that appears to be very strange for a total noob like me.
I've written and run the following simple code that counts from 0x0000 to 0xFFFF, and sends the value in hex notation to the serial port.
------------
word i;
void setup(){
Serial.begin(9600);
Serial.println("Start counting !");
for (i = 0; i <= 0xFFFF; i++) {
Serial.println(i,HEX);
if (i == 0xFFFF) {
Serial.println("FFFF reached !");
}
}
Serial.println("Count finished!");
}
void loop()
{
}
------------
Looking at the serial monitor in the Arduino IDE, when I run this code, the setup() routine, that I thought would be run only once, is instead executed repeatedly, and the line that prints "Count finished!" is never executed, and appears to be always skipped.
Why is that ?
It looks like the Teensy is being reset at the end of the for loop.
How can I make the program do something after the first for loop ?
Thanks in advance for any help.
Last edited: