ZBasic Language Reference
68
ZBasic Microcontrollers
Example
Dim tick as Long
tick = Register.RTCTick
In addition to the particular registers available for each underlying processor, three special register
variables are provided that correspond the PORT, PIN and DDR registers associated with a particular I/O
pin. The form of these three special register functions is: Register.Port(<pin>),
Register.Pin(<pin>) and Register.DDR(<pin>), respectively. In all three cases, the property
.DataAddress may be appended to get the address of the register associated with the specified pin.
Example
val = Register.Port(C.2)
' reads Register.PortC
Register.Port(C.2) = val
' writes to Register.PortC
addr = Register.Pin(A.4).DataAddress
' address of Register.PinA
These three special register variables will often be used in conjunction with the ZBasic System Library
function PortMask() which returns the bit mask for an I/O port corresponding to a specified pin.
Example
Const pin as Byte = C.7
Call SetBits(Register.DDR(pin), PortMask(pin), &Hff)
' make a pin an output
3.7.1 Special Function Registers
Each supported target processor has a number of special function registers (SFRs), some of which are 8
bits wide and some of which are 16 bits wide. The SFRs can be accessed in application code by adding
the prefix Register. to the SFR name, e.g. Register.PortC for the register PORTC. For the details
on the purpose and use of each SFR, see the manufacturers datasheet for the particular target
processor.
The SFRs for the supported targets are described in a series of XML resource description files located in
a subdirectory of the ZBasic installation directory. See Appendix N for more information on the resource
description files.
3.7.2 System Variables and Constants
Some of the ZBasic register values allow access to certain variables used by the system control program
as described below. Unless otherwise indicated, the registers are readable and writable. However, for
some of the variables, modifying their values may have undesirable or unpredictable effects on your
program. See the descriptions of the individual items for more information.
BasicX Compatibility Note
In BasicX mode, only a subset of the variables described below is available, being
limited to those that are also present in BasicX. Those that are available in BasicX
mode are specifically identified in their descriptions.
Register.BootVersion
This UnsignedInteger value gives the version number of the bootloader installed on the ZX device.
The high byte gives the major value while the low byte gives the minor value. For example, if the
bootloader version number is v1.4, the value of Register.BootVersion will be &H0104.
|