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
| Limit | Value |
|---|---|
| Max script size | 8 192 bytes |
| Max variables | 32 (signed 32-bit integers) |
| Max operations per loop iteration | 512 |
| Loop period target | 1 ms |
Error Conditions
If the script encounters any of the following, it is immediately stopped and all flags are cleared:
| Error | Cause |
|---|---|
| unknown instruction | An instruction the firmware does not recognise was executed |
| hardware operation failed | A hardware block (e.g. I2C, acquisition) returned an error |
| division by zero | Integer division or modulo with a zero divisor |
| loop iteration took too long (> 512 operations) | The loop body exceeded its per-iteration budget |