User Tools

Site Tools


digispark:tricks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
digispark:tricks [2013/05/19 14:36]
RC Navy [<TinySoftPwm> library features]
digispark:tricks [2013/10/16 01:40] (current)
digistump [Get rid of 5 second startup delay]
Line 3: Line 3:
 ====== Detect if system clock was calibrated ====== ====== Detect if system clock was calibrated ======
  
-When the digispark boots up, it uses the USB signal to calibrate ​it'​s ​clock to 16.5mhz. When powered by an external power supply this doesn'​t happen and the clock speed is closer to 16.0mhz, with roughly 10% accuracy. If you want to detect if the clock was calibrated before starting your program you can use these two functions:+When the digispark boots up, it uses the USB signal to calibrate ​its clock to 16.5mhz. When powered by an external power supply this doesn'​t happen and the clock speed is closer to 16.0mhz, with roughly 10% accuracy. If you want to detect if the clock was calibrated before starting your program you can use these two functions:
  
 <code c> <code c>
Line 32: Line 32:
 ====== Reboot in to the bootloader from your program ====== ====== Reboot in to the bootloader from your program ======
  
-In some situations you might find it difficult to unplug and reconnect the digispark in order to replace ​it'​s ​program. You can use the function below to reboot in to the bootloader without needing to disconnect the digispark physically.+In some situations you might find it difficult to unplug and reconnect the digispark in order to replace ​its program. You can use the function below to reboot in to the bootloader without needing to disconnect the digispark physically.
  
 <code c> <code c>
Line 48: Line 48:
 ====== Get rid of 5 second startup delay ====== ====== Get rid of 5 second startup delay ======
  
-When the digispark is powered up, it waits 5 seconds to give your computer a chance to upload a different program. For some projects this delay is less than ideal. For these situations we have another version of the bootloader which only accepts uploads if you connect D5 to ground with a wire or a button before plugging the digispark in. You can add an '​update'​ button to your project for times you want to change ​it'​s ​software, and use the button for other stuff in your app, or use the reboot to bootloader code above to make it reboot and accept a program without having to unplug and replug the device.+When the digispark is powered up, it waits 5 seconds to give your computer a chance to upload a different program. For some projects this delay is less than ideal. For these situations we have another version of the bootloader which only accepts uploads if you connect D5 to ground with a wire or a button before plugging the digispark in. You can add an '​update'​ button to your project for times you want to change ​its software, and use the button for other stuff in your app, or use the reboot to bootloader code above to make it reboot and accept a program without having to unplug and replug the device.
  
 Instructions are on the forum for [[http://​digistump.com/​board/​index.php/​topic,​320.msg1711.html#​msg1711|Mac]] and [[http://​digistump.com/​board/​index.php/​topic,​320.msg1778.html#​msg1778|Windows]]. Linux users should follow the Mac instructions pretty much. Note that this is an unsupported modification and does currently void your digispark'​s warranty. So far nobody seems to have had any trouble with it though. Instructions are on the forum for [[http://​digistump.com/​board/​index.php/​topic,​320.msg1711.html#​msg1711|Mac]] and [[http://​digistump.com/​board/​index.php/​topic,​320.msg1778.html#​msg1778|Windows]]. Linux users should follow the Mac instructions pretty much. Note that this is an unsupported modification and does currently void your digispark'​s warranty. So far nobody seems to have had any trouble with it though.
  
 +The newest version of the jumper firmware can be found here: https://​github.com/​Bluebie/​micronucleus-t85/​tree/​master/​upgrade/​releases
  
 ====== Debug with blinkenlights ====== ====== Debug with blinkenlights ======
Line 100: Line 101:
 You can use an I/O pin as a ground/+5V if you have some left and the current that flow in it is low (a few milliamps if you want the pin to stay around 0V/+5V. If you don't care about the exact voltage you can go up to 40mA per pin  according to the datasheet but it's good to keep a safety margin). You can use an I/O pin as a ground/+5V if you have some left and the current that flow in it is low (a few milliamps if you want the pin to stay around 0V/+5V. If you don't care about the exact voltage you can go up to 40mA per pin  according to the datasheet but it's good to keep a safety margin).
  
-Configure the pin as an output and set it'​s ​value to either LOW or HIGH (for ground or +5V).+Configure the pin as an output and set its value to either LOW or HIGH (for ground or +5V).
  
 For example to connect a button between pin 0(set as input) and pin 2(acts as ground): For example to connect a button between pin 0(set as input) and pin 2(acts as ground):
Line 227: Line 228:
 For example, if //​%%MS_TIMER_TICK_EVERY_X_CYCLES%%//​ is set to 8, the obtained frequencies are 8 time smaller. For example, if //​%%MS_TIMER_TICK_EVERY_X_CYCLES%%//​ is set to 8, the obtained frequencies are 8 time smaller.
 ===== Software PWM ===== ===== Software PWM =====
-To use software PWM in your sketch, use the //​TinySoftPwm_analogWrite()//​ function (just add the //​TinySoftPwm_//​ prefix).\\ ​ 
- 
 New Digispark IDE release (may 2013) introduces a new library: <​TinySoftPwm>,​ a tiny Software PWM library.\\ ​ New Digispark IDE release (may 2013) introduces a new library: <​TinySoftPwm>,​ a tiny Software PWM library.\\ ​
 +
 +To use software PWM in your sketch, use the //​TinySoftPwm_analogWrite()//​ function (just add the //​TinySoftPwm_//​ prefix to the common analogWrite() function).\\ ​
 +
 ==== <​TinySoftPwm>​ library features ==== ==== <​TinySoftPwm>​ library features ====
   * Easy to use, only 3 functions:​\\ ​   * Easy to use, only 3 functions:​\\ ​
-    * TinySoftPwm_begin() which shall be called in the setup() function+    * TinySoftPwm_begin()which shall be called in the setup() function
     * TinySoftPwm_analogWrite()     * TinySoftPwm_analogWrite()
-    * TinySoftPwm_process() which shall be called periodically in the main loop or in timer interruption+    * TinySoftPwm_process()which shall be called periodically in the main loop or in timer interruption
   * Can configure all the 6 pins of the Digispark for software PWM   * Can configure all the 6 pins of the Digispark for software PWM
   * Compact: each additional declared PWM pin requires around 60 bytes   * Compact: each additional declared PWM pin requires around 60 bytes
digispark/tricks.1368999387.txt.gz · Last modified: 2013/05/19 14:36 by RC Navy