32bit Controller Enhancements
Other than early examples of the EC1 and some DIN Family controllers, SPLat 32 bit controllers are identified by their black PCBs. These controllers add several enhancements to the SPLat VM as described below.
SPLat/PC Simulator
The SPLat/PC simulator does not support any of these enhancements. We recommend you only use the simulator as a learning tool or to test small routines. Full application debugging can only be performed on the controller using SPLatlink or instructions like iiPrintText to output debug information via the serial port.
Enhanced MultiTrack implementation
32 bit controllers benefit from having much more memory in the processor chip than our classic 8-bit controllers. This has allowed us to enhance MultiTrack:
- Each task has its own register stack (
X, Y, Z, T
),I, R
, its own NVEM registers and its own floating point registers W & Q. That means you can hold temporary results in registers during yielding instruction likeYieldTask
,Pause
,WaitOn
, etc and it will still be there when you resume. In other words, your registers won't be changed when other tasks run. Only U & V are shared by all tasks. - When a task is launched, its registers (except
R
) are set to the same values as in the task that launches it. This provides a good way of launching tasks with initial parameters. At start-up the default task is deemed to be running (before anyRunTasksForever
). - Each task has its own subroutine return stack. That means you can execute a yielding instruction inside subroutines, like YieldTask, Pause, WaitOn, etc.
MarkTime
&Pause
use separate timers, so they can be active at the same time. Whence you can Pause in a LoopIfTiming loop.MarkTime
,fSTSinceMark
,LoopIfTiming
are available even if you're not using MultiTrack, ie, you can use them even if you're single tasking.- Each task has its own SuperTimer scaling (more details below)
- 128 tasks (up from 32)
- Up to 1024 instructions between Yield or Pause statements (up from 256)
PWM base frequency
The analog outputs on most 32 bit controllers are in reality pulse width modulated digital outputs. They can be filtered to produce an analog voltage. The duty cycle (percentage ON time) of the signal is proportional to the number sent to the output by an fAnOut
instruction. The default frequency of the PWM signal is 40kHz. This can be changed by executing the following code:
SetU 0,U0
SPxCmd1 0,!CPU
where U0
is taken from the following table:
U0 | PWM frequency |
---|---|
0 | 16kHz |
1 | 8kHz |
2 | 4kHz |
3 | 2kHz |
4 | 1kHz |
5 | 500Hz |
6 | 250Hz |
7 | 125Hz |
8 | 50Hz (RC servo) |
The 50Hz frequency is particularly suitable for driving RC (hobby) servo motors. The other frequencies give a range of choices for, for example, controlling the speed of DC motors.
Modify SuperTimer 10mS clock interval per task
You can change the basic 10mS SuperTimer clock interval to some other value. Set U0 to the required value in mS and then execute a
SPxCmd1 1,!CPU
The default interval is 10mS. Example, set the SuperTimer clock interval to 3mS:
SetU 0,3
SPxCmd1 1,!CPU
This change will affect only the timing of the MultiTrack task that executes it. Other tasks will continue to run at 10ms or whatever you have changed each of them to.
NVEM writes
The flash memory architecture of the processor used in 32 bit controllers is not conducive to having a SPLatWare program writing to NVEM. Many of these controllers will have NVEM1, so check the documentation for your specific controller. Some also have NVEM2 (RAM, up to 64KB on some boards), NVEM3 (battery-backed - where there's a battery - RAM, from 20 bytes on HMI boards to 4KB on some) and NVEM4 (Flash-based NV memory).
Serial Expansion via XwIre (SEXI)
32 bit controllers support SEXI when running as an Xwire Master. This means any 8 bit or 32 bit Xwire slave can have its I/O mapped into the master's I/O space. All the usual instructions will work, including Blink, Input, Off, GoIfInK, fAnIn, fAnOut, etc. SPLat/PC will also show the additional I/O in the digital and analogue windows.