22 of 208
ZBasic Language Reference 14 ZX Microcontroller Family Option ExtRamConfig Option ExtRamConfig [On | Off | <constant-expression>] Default: (see text) For ZX devices that support external RAM, you may control whether external RAM is enabled using this directive. Using the keyword On enables external RAM support in the default configuration (16-bit address, no wait states). If you need a different configuration, you may specify a constant expression whose 16-bit value is written to the external RAM configuration registers of the CPU. For ATmega-based devices, the high byte is written to the register XMCRB register and the low byte is written to XMCRA register. (Note that for the mega128 CPU, the high bit of the XMCRA register is undefined but the configuration value must have that bit asserted in order for the external RAM interface to be enabled.) For ATxmega-based ZX devices, the low byte is written to the EBI_CTRL register while the high byte is written to the EBI_CS1_CTRLB register. For ATmega-based device, the default external RAM configuration value is &H0080. For ATxmega- based devices, the default external RAM configuration value is &H014d. Examples Option ExtRamConfig On Option ExtRamConfig &H0084 ' enable with 1 wait state (ATmega) Option RamSize Option RamSize <constant-expression> Default: (see text) The compiler compares the aggregate size of the statically allocated data items to the amount of RAM available in the target device. If the aggregate size is too large, the compiler issues a warning to that effect. For ZX models that support external RAM (e.g. ZX-1281), the compiler must know the resultant size of User RAM in order to avoid generating meaningless warnings. That is the purpose of this directive, which may only be used on ZX models that support external RAM. The example below shows the simplest way of specifying the augmented User RAM size. The example is for the case where the maximum amount of additional RAM was added. Example Option RamSize 65536 – Register.RamStart Option HeapSize Option HeapSize <constant-expression> Default: (see text) This directive controls the allocation of RAM between the string heap and the Main() task stack. The effect is to set a hard limit beyond which the heap will not grow, thereby preventing the heap from encroaching on the Main() task stack. If a size less than the minimum size (64 bytes) is specified, the minimum is used instead. Also, for devices with external RAM, the special value of 65535 (&HFFFF) can be used to specify that all external RAM should be used for the heap. The default heap size is 256 bytes for VM mode devices and 512 for native mode devices. See the section on setting heap and task stack sizes for more information. For VM mode devices the directive has an additional effect. When the compiler performs various checks regarding the use of RAM, it takes into account an amount of RAM reserved for the heap (from which memory for strings, for example, is allocated). The size specified for the heap will effect whether the compiler will issue a warning about excessive use of RAM in a particular circumstance.