FANDOM


Miscellaneous Commands Intro Edit

This chapter includes the "normal" BASIC commands that are included with most versions of BASIC, as well as commands specific to Atom BASIC. Read it carefully: some familiar commands may be defined somewhat differently in Atom BASIC.

This chapter contains the following sections:

  • Miscellaneous Commands
    • End, Stop
    • High, Low, Toggle
    • Input, Output, Reverse
    • Pause
    • Pauseclk
    • Pauseus
    • Nap
    • Sleep


Conventions Used in this Chapter Edit

{ ... } represent optional components in a command. The { } are not to be included.
[ ... ] used for lists - the [ ] are required.
( ... ) used for some arguments. The ( ) are required.


END, STOP Edit

These commands stop program execution and place the Atom Pro in low power mode. All I/O pins will remain in their current state.

END and STOP are identical in function.

Syntax

END
STOP

Notes

To restart a stopped program, press the RESET button on the Atom Pro or power the Atom Pro OFF and back ON.


HIGH, LOW, TOGGLE Edit

HIGH configures a pin as output and sets it high.

LOW configures a pin as output and sets it low.

TOGGLE configures a pin as output and switches its state from high to low or low to high.

Syntax

high pin
low pin
toggle pin
pin is a variable or constant that specifies the I/O pin to use.

Examples

high P4 ; makes P4 an output and sets it high (5V)
low P10 ; makes P10 an output and sets it low (0V)
high P4 ; makes P4 an output and sets it high.
toggle P4 ; switches P4 from high to low.


INPUT, OUTPUT, REVERSE Edit

INPUT sets a pin to be an input.

OUTPUT sets a pin to be an output but does not set its state.

REVERSE reverses the direction of a pin.

Syntax

input pin
output pin
reverse pin
pin is a variable or constant specifying the I/O pin affected.

Notes

These commands let you set the direction of a pin. Note that several commands (e.g. high, low, etc. automatically set the direction of certain pins so it may not be necessary to set them using input, output or reverse. This behavior is documented for the individual commands.

Examples

input P8 ; sets I/O pin 8 as an input.
output P9 ; sets I/O pin 9 as an output
serout P5\P6,NEO2400,5000,expd,[dec ant,bat,hex4 cat\4]
  ; program continues here
input P5 ; change P5 to an input

In the last example, the serout command has set P5 to an output. Later, the input command is used to change it to an input.


PAUSE Edit

Pause execution for a specified number of milliseconds.

Syntax

pause milliseconds
milliseconds is a variable or constant specifying the number of milliseconds (up to 32 bits, or 4,294,967,295 ms).

Notes

Pause is used to delay program execution. The duration of the pause can be from 1 ms to 4,294,967 seconds (which is approximately 1193 hours, or 49.7 days).

While it is unlikely that longer pauses than this will be required, times shorter than 1 ms may be obtained with the pauseus and pauseclk commands.

Examples

See the traffic light program on page 23 for one example where pause could be used. Another example is shown under I2COUT on page 120.


PAUSECLK Edit

Pause execution for a specified number of clock cycles. PAUSECLK is most useful for very short times, for longer times use PAUSE or PAUSEUS.

Syntax

pauseclk cycles
cycles is a variable or constant (up to 32 bits) specifying the number of clock cycles to pause.

Notes

Clock periods and timing are shown in the table below.

Clock Period Minimum Maximum
Atom Pro 16 MHz 62.5 ns 62.5 ns 268 s (4 m 28 s)
Atom Pro Plus 20 MHz 50.0 ns 50.0 ns 215 s (3 m 35 s)

Examples

With an Atom Pro:

pauseclk 2000

will cause program execution to pause for 2000 x 62.5 ns, or 125 µs.


PAUSEUS Edit

Pause execution for a specified number of microseconds.

Syntax

pauseus microseconds
microseconds is a variable or constant specifying the number of microseconds to pause, up to 32 bits.

Notes

The pauseus command is used to pause program execution for short periods of time (from 1 µs to 4,294,967,295 µs, which is approximately 4,295 seconds, or 71.6 minutes, or 1.2 hours).

The resolution of the pauseus command is 1000 times smaller than that of the pause command and 5 times greater than the pauseclk command.


NAP Edit

The NAP command executes the processor's internal sleep mode for the specified time period. Power consumption is reduced in sleep mode. NAP is essentially a simplified version of SLEEP (see page 131).

Syntax

nap period
period is a variable or constant that determines the duration of the reduced power nap in units of 2 ms.

Notes

Times are approximate and may vary with temperature, supply voltage and manufacturing tolerances.

The Atom Pro will immediately wake up from a nap if an interrupt occurs.

The NAP command does not affect internal registers so your program will continue executing when the time expires.

Example

nap 2000

will put the Atom Pro in low power sleep state for 40 seconds.


SLEEP Edit

The SLEEP command is similar to the NAP command except that it adds a number of options. To achieve minimum power consumption set all I/O pins to output and in the low state. (Don't set pins to "output" if they are connected to the outputs of other devices!)

Syntax

sleep time{,mode}
time is a variable or constant (up to 32 bits) that specifies the duration of the sleep in 2 ms increments (see the Important Note below).
mode is an optional parameter with several possible values as described below. If mode is not specified, the sleep command is equivalent to the nap command.

Modes

Standby mode puts the processor to sleep and turns off the oscillator to save power. An external interrupt or reset must be used to wake up the processor. The time parameter is ignored.

SLEEPSTANDBY Enter standby, wake on external interrupt.

The following modes cause the clock multiplier to be set and puts the processor to sleep for the specified time.

SLEEPACTIVE Normal sleep (default)
SLEEPACTIVE_8 1/8 system clock sleep
SLEEPACTIVE_16 1/16 system clock sleep
SLEEPACTIVE_32 1/32 system clock sleep
SLEEPACTIVE_64 1/64 system clock sleep

Important: If the clock multiplier is set to 8, 16, 32 or 64 the 2 ms time increment is multiplied by the same factor. 14 Don't set pins to "output" if they are connected to the outputs of other devices!

The following modes change the clock speed divisor without putting the processor to sleep. The time parameter is ignored.

DIRECTACTIVE Normal system clock
DIRECTACTIVE_8 1/8 system clock
DIRECTACTIVE_16 1/16 system clock
DIRECTACTIVE_32 1/32 system clock
DIRECTACTIVE_64 1/64 system clock

Same as DIRECTACTIVE except that all system registers, TimerV, SCI3 and the AD hardware are reset. The time parameter is ignored.

DIRECTACTIVERES Normal system clock
DIRECTACTIVERES_8 1/8 system clock
DIRECTACTIVERES_16 1/16 system clock
DIRECTACTIVERES_32 1/32 system clock
DIRECTACTIVERES_64 1/64 system clock

Notes

Examples

sleep 3000

will put the Atom Pro in low power sleep state for approximately 6 seconds.

sleep 3000,sleepactive_8

will reduce the clock rate by a factor of 8, and put the Atom Pro in low power sleep state for approximately 48 seconds.

sleep 1,sleepstandby

will put the processor to sleep and turn off the oscillator. The processor will start when a reset or external interrupt is received. The time parameter (1, in this case) is ignored.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.