Running Your Word at Start Up
When FlashForth starts (or resets), it can be configured to run any word from the dictionary by mapping that word to the turnkey word. This is particularly useful if you have created an embedded application that you want to run automatically whenever your Udamonic computer is turned on.
In this example, myWord is made to launch at start up:
In this example, myWord is made to launch at start up:
' myWord is turnkey
The tick word ' searches the dictionary for the name of the word (specified by the string of characters immediately after ' ), and places the address of myWord on the stack. The word is then stores the address to the dictionary entry for turnkey. Once you've set turnkey, use the word warm to restart your Scamp. This causes the value for turnkey to be saved to flash. From now on, a cold restart, warm restart or brownout reset will cause turnkey to run at startup.
On restart, if turnkey is 0 (false), FlashForth starts normally. If turnkey is not zero, it is treated as a token (pointer) to a word to be run. The RESET button on your Udamonic computer will restart FlashForth without turnkey running. In this way you can use RESET to bypass turnkey, if you need to disable it or change it. Other sources of restart (such as power-on, brown-out reset, warm etc) will execute turnkey immediately.
|
Note: If the startup word pointed to by turnkey is removed, turnkey will still attempt to execute whatever it finds at that address in the dictionary. So, always remember to disable turnkey if you forget (remove) your startup word.
|
|
To disable turnkey, just set it to false (zero):
false is turnkey
Note that when setting it to false, no tick ' is required. That's because you're setting turnkey to be zero, not the address of false in the dictionary.
Powering Your Scamp
When developing code, your Scamp can be powered by USB alone. However, in standalone applications, USB power is usually not available. You can provide an external power source for your Scamp via the VIN pin. Anything from 5V to 12V is suitable.
The 3V3 pins on the main connector are outputs from the onboard regulator and provide regulated 3V3 power to external devices. All 3V3 pins are connected together. For external devices that draw a lot of current, use multiple 3V3 pins for power.
The 3V3 pins on the main connector are outputs from the onboard regulator and provide regulated 3V3 power to external devices. All 3V3 pins are connected together. For external devices that draw a lot of current, use multiple 3V3 pins for power.
|
Do not connect external power sources to the 3V3 pins.
|
|