Dаrren Kitchen Posted July 1, 2010 Share Posted July 1, 2010 I've encountered a problem with millis() function in Teensyduino.It seems that after my program runs for awhile, the clock on the Teensy seems to slow down and not give accurate results. It seems to be a side effect of me using my "CommandAtRunBarMSWIN" function, but the only time related function I use in it is delay() and when I tested with just that it the loop did not seem to skew the clock. I'm using the latest alpha to my knowledge. Ideas? Adrian void CommandAtRunBarMSWIN(char *SomeCommand){ //digitalWrite(ledPin, HIGH); // set the LED on Keyboard.set_modifier(MODIFIERKEY_RIGHT_GUI); //Windows key Keyboard.set_key1(KEY_R); // use r key Keyboard.send_now(); // send strokes Keyboard.set_modifier(0); //prep release of control keys Keyboard.set_key1(0); //have to do this to keep it from hitting key multiple times. Keyboard.send_now(); //Send the key changes delay(1500); Keyboard.print(SomeCommand); Keyboard.set_key1(KEY_ENTER); Keyboard.send_now(); Keyboard.set_key1(0); Keyboard.send_now(); } Quote Link to comment Share on other sites More sharing options...
Dаrren Kitchen Posted July 1, 2010 Author Share Posted July 1, 2010 Ok, more info on the problem. It only happens when I use the SD card, and USB type "Disk(SD Card)+Keyboard". Just "Keyboard+Mouse" does not have the time drift. Quote Link to comment Share on other sites More sharing options...
Dаrren Kitchen Posted July 1, 2010 Author Share Posted July 1, 2010 Paul explained it to me, seems using the SD takes a lot of CPU time on the Teensy, and causes the clock to have issues. Quote Link to comment Share on other sites More sharing options...
BITS1 Posted July 1, 2010 Share Posted July 1, 2010 Paul explained it to me, seems using the SD takes a lot of CPU time on the Teensy, and causes the clock to have issues. So does that mean we shouldn't use the clock? Or we should add more delay time? I wonder, does it have the same effect on all operating systems? I'm getting ready to incorporate the sd card to the Teensy and I just want to know whether this will cause problems later on... Thanks for your posts, it really helps me understand how to use Teensy. I'm still new at this..:] Bits1 Quote Link to comment Share on other sites More sharing options...
Dаrren Kitchen Posted July 2, 2010 Author Share Posted July 2, 2010 I'd imagine it would effect all operating systems since it seems to be an issue with CPU time on the Teensy. Also, the SD will only be at 1.1 speeds. If you plan to copy files to storage, use a hub and a USB 2.0 device, like I did in my Trojaned mouse. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.