ZBasic Language Reference
use a 14.7MHz crystal and run at 29.5MHz. They would work equally well with any 12-16MHz crystal
frequency if an internal 2X operating speed is desired. The default values configure the xmega to run on
the internal 2MHz RC oscillator.
Option DeviceParameter clkCtrl "0x04"
Option DeviceParameter psCtrl "0x03"
Option DeviceParameter oscCtrl "0x08"
Option DeviceParameter xoscCtrl "0xcb"
Option DeviceParameter pllCtrl "0xc8"
5.4 ZBasic Bootloader
The ZBasic Bootloader facilitates downloading of code to a generic target device without needing special
programming hardware. Such hardware is needed, of course, for the initial installation of the bootloader
but after bootloader installation application code can be downloaded without the programming hardware.
The ZBasic installer automatically installs the source code, build scripts and related files for the ZBasic
Bootloader. These can be found in the zboot subdirectory of the ZBasic installation directory. Pre-built
bootloaders for the supported devices are also installed (see zboot/boot). The pre-built bootloaders
are configured for devices running at 16MHz (important for ATtiny and ATmega devices only) and a
download speed of 115.2K baud. If you want a different download speed or your ATTiny/ATmega runs at
a different speed, youll have to rebuild to get a compatible bootloader image.
The easiest way to build a bootloader image is to use the batchfile makeboot.bat. Near the beginning
of that file youll find several configuration items including the operating frequency (F_CPU), the download
baud rate (BAUD) and the target device (DEVICE). For xmega devices, youll need to set BAUD_SEL to
select the baud rate; BAUD and F_CPU arent used in that case. After making the desired changes, run
the batchfile to effect the build; the resulting .hex file containing the bootloader will then be found in the
boot subdirectory in a file named for the device, e.g. zboot\boot\atmega644p_boot.hex for the
If you are using Windows Vista or later, you'll need to copy the bootloader source directory from the
installation directory to some other directory outside of the "Program Files" system directory because
those later Windows versions do not allow applications to change files in the "Program Files" directory