Skip to main content

Program Structure

Setup Section​

The Setup section runs once when the script starts. Use it to:

  • Initialize hardware (acquisition, I2C devices)
  • Declare variables and set their initial values
  • Configure the sample rate

The setup section runs once when the script starts. After it completes, the VM transitions to the loop.

Loop Section​

The Loop section runs repeatedly at a target period of 1 ms.

Each iteration has a budget of 512 operations. If more than 512 operations execute in a single pass, the script stops with a "loop iteration took too long" error.

Variables declared in Setup persist across loop iterations — they are not cleared between passes.

Script Limits​

LimitValue
Max script size8 192 bytes
Max variables32 (signed 32-bit integers)
Max operations per loop iteration512
Loop period target1 ms

Error Conditions​

If the script encounters any of the following, it is immediately stopped and all flags are cleared:

ErrorCause
unknown instructionAn instruction the firmware does not recognise was executed
hardware operation failedA hardware block (e.g. I2C, acquisition) returned an error
division by zeroInteger division or modulo with a zero divisor
loop iteration took too long (> 512 operations)The loop body exceeded its per-iteration budget