CB2 micro
User manual
Go back to the main site
About this manual

After you have successfully assembled your CB2 micro KIT, you should use this manual to get started with the CB2 micro. This manual describes the basic operation of the computer and some of the features available into it. New features can be added by loading and running new programs of course, as well as making your own BASIC programs. 



Quick index reference


Click on a word in the table below to navigate to the relevant section of the manual. Then use "back" on your browser to return to this table.


1 Initial power up

2 The keyboard


3 The main menu
3.1 Editing a program (F1)
3.2 Save program (F2)
3.3 Load program (F3)
3.4 Start program (F4)
3.5 Copy program (CTRL+F1)
3.6 Send program (CTRL+F2)
3.7 Receive program (CTRL+F3)
3.8 Delete program (CTRL+F4)
3.9 Binary programs, libraries and drivers

4 The Flashmanager

4.1 Info (F1)
4.2 Backup (F2)
4.3 Restore (F3)
4.4 Delete (CTRL+F1)
4.5 Format (CTRL+F4)

5 The configuration menu
5.1 The assignment of the function keys
5.1.1 Exit (ESC)
5.1.2 Change (F1)
5.1.3 Serial speed
5.1.4 I2C speed
5.1.5 SPI speed
5.1.6 EEPROM address
5.1.7 End of line
5.1.8 Serial Interface - Type
5.1.9 Serial interface - input pin
5.1.10 Autostart
5.1.11 Save (F2)
6 The fullscreen editor
6.1 Special key functions
6.2 The search function

7 Serial program transfer
7.1 Communication parameters Standard interface
7.2 Communication parameter extended interface
7.3 Sending to the CB2 micro (BASIC program text)
7.4 Receiving from the CB2 micro (BASIC program text)
7.5 Send to the CB2 micro (binary files)
7.6 Receiving from the CB2 micro (binary files)
7.7 Use of the screenshot function

8 The integrated monitor/debugger
8.1 The main screen
8.2 The Array View

9 The communication program CBTerm mini
9.1 The assignment of the function keys
9.1.1 Exit (ESC)
9.1.2 Mode (F1)
9.1.3 Send (F2)
9.1.4 Receive (F3)
9.1.5 Clear (F4)
9.1.6 Transferred characters

10 The communication program Colterm
10.1 The communication protocol
10.2 Graphics transfer
10.3 Sound transfer
10.4 Handling transmit/receive priority


1 Initial power up

After you have successfully assembled your CB2 micro KIT, configured J1 for PAL/NTSC, connected all the cables to the TV, to the keyboard and the power, your computer should boot up ok. When you first power it up, an intro screen appears for a few seconds and then the main menu area appears. The main menu area is comparable to the desktop of a PC and contains, among others, the 8 program slots. These slots are positions where you can store your programs. The BC2 micro KIT, comes with a pre-programmed chip and the 8 program slots are pre-filled with different programs and games that you can try right away. When you want to write your own program you have to free one of these slots by selecting it and pressing CTRL+F4 to erase the previous stored program. Then you press F1 to edit the BASIC program in this empty slot. 

2 The keyboard

The CB2 micro KIT, comes preprogrammed and ready to be used. However, if you wish to re-program the micro, note that the present version of the firmware requires initially a keyboard with German layout. But the keyboard layout can be changed by means of a binary program afterwards. The current layout is displayed in the main menu at the bottom of the screen.

For quicker access to the different options, there are 5 colored fields at the bottom menu of the screen with functions that correspond to the keys ESC, F1, F2, F3 and F4.
If you like, you can use colored stickers on your keyboard so that these keys can be found more quickly.


Apart from these 5 keys, there are a few more keyboard shortcuts, some of which are similar to the PC shortcuts:
When the running program is stopped or interrupted (abort or error), the color of the screen changes to a red and white stripe pattern. The ESC key then returns you to the editor or to the main menu. At this point it is also possible to send a screenshot.

3 The main menu

After each power on or reset, the intro screen is displayed for approx. 3 seconds. Then the main menu is brought up, except when the autostart option is activated. In this case, the preset program will be started automatically. The intro screen can be canceled at any time by pressing a key (except Shift, CTRL, ALT), in which case a preset autostart function will be bypassed and not executed. A special case is when a serial LOADER program is installed. In this case, we call the LOADER program before starting the autostart program. You can also switch to a small "Keyboard Monitor" by pressing the right shift key to view the received scan codes. This mode can only be exited by a restart.



In the "window" of the main screen, the 8 programs and 3 additional functions are arranged as symbols, including the name or the program name. Use the cursor keys to move and hilight the programs fields (slots), then press the Enter key to start the program under the hilighted field or to call the corresponding function. The color of the symbol indicates the type of program. On binary programs, the icon of the program file is displayed.


colour program type
White BASIC program
Green Program saved as text
Yellow Binary program
Cyan Library
Magenta Video driver, can only be used on program slot 8
Red Loader program, can neither be edited nor started


The 3 symbols in the third line, show the Flashmanager, the Config-Page and the info program. For details on them, see the relevant sections in this manual. Underneath there is an indicator for the system status. On the far left line is the MCU type, either 644 for the ATMega644 or 644P for the ATMega644P. In addition, the current active video system (PAL or NTSC) is displayed. On the right, there is the short name of the active keyboard layout. To change the keyboard layout, a corresponding (binary) program must be loaded and started. For example, with the program "kbd_us.bin" (provided) the keyboard layout can be changed to US-English. For this purpose, the program is either transmitted via XMODEM or loaded from the disk module. After the program has been executed with the F4 key, the display changes accordingly in the system status. However, as the CB2 micro comes pre-programmed, you do not need to worry about the keyboard layout at all, unless you have a German keyboard layout. The bottom line menu contains the possible commands, the colors correspond to the keys ESC and F1...F4 and have the following functions:

No function
For BASIC programs, the editor is called
Saves the program on a Dataflash module
Loads the program from a Dataflash module
Starts the program



3.1 Editing a program (F1)

Calls the built-in editor and loads the selected program. This only works for BASIC and empty programs. Binary programs and binary libraries can not be edited.

3.2 Save program (F2)

This function refers to the currently selected program slot on the main screen (desktop). It is not used by the CB2 micro, unless you have added an external dataflash module to it. If it is called when no formatted external dataflash is connected to the circuit, an error message appears. If a formatted dataflash is connected, the location where the file should be saved can be determined using the file selection box:



It should be noted that only empty slots or BAS/AVR files can be written. The selection can also be canceled with the ESC key. Before a file is overwritten, this must be confirmed again with "Y".

3.3 Load program (F3)

This function refers to the currently selected program slot in the main screen. It is not used by the CB2 micro, unless you have added an external dataflash module to it. If it is called and no formatted dataflash is connected to the circuit, an error message appears. If a formatted dataflash is connected, the program to be loaded can be selected with the file selection box:



It should be noted that only BAS and AVR native binary files can be read. The selected file will be copied into the internal flash of the controller (into the currently selected slot in the desktop) without further notice. The selection can also be canceled with the ESC key.


3.4 Start program (F4)

Starts the selected program. This works for both BASIC and native AVR programs. After completing or aborting the program (error, CTRL-C), a red and white stripe pattern appears on the edge. The ESC key then returns back to the menu. At this point, a screenshot can be made, but the border color is generally output as black. This also applies if a program is started from the editor.

The keys F1...F4 have a secondary function if the left or the right CTRL key is pressed additionally. The texts in the 5 color fields change accordingly:


Copies the program to another program slot
Sends the program via X-modem
Receives the program via X-modem
Delete the program



3.5 Copy program (CTRL+F1)

To test different program versions without a Dataflash module, each program can be copied to one of the 8 program slots. The copy destination can then be selected with the cursor keys, and by clicking the ENTER key the program is copied without prompting. The operation can be aborted with the ESC key.



3.6 Send program (CTRL+F2)

With this function a program can be sent in binary format via X-Modem. This can be used for example to transfer a program to another CB2 micro or to the PC. For native AVR programs, this is also the only way to transmit data, since AVR programs can not be edited and transferred through the editor. To start the transfer, you must first activate the transmission (CTRL+F2) locally and then initiate the reception on the remote receiver side.

3.7 Receive program (CTRL+F3)

With this function a program can be received in binary format via X-Modem. For native AVR programs, this is also the only way to receive data, since AVR programs can not be edited and transferred through the editor. To start the transfer, first activate the remote transmitter side and then initiate the local reception with CTRL+F3.

3.8 Delete program (CTRL+F4)

Native AVR programs can not be deleted using the editor, but this can be done with the keyboard shortcut CTRL+F4. After a confirmation prompt the program will be deleted. Of course you can also delete BASIC programs or any other programs that way.



3.9 Binary programs, libraries and drivers

Binary programs, which include libraries and drivers, can be loaded on any of the 8 program slots. However, drivers only work if they are loaded on program slot 8.

4 The Flashmanager

The Flash Manager (DFLASH icon in the main menu) only works if a Dataflash external module is plugged in. Otherwise there is only the option to rescan and cancel. The CB2 micro KIT does not include an external dataflash, so this option cannot be used, unless you connect one yourself.
If however a Dataflash module is present (only 4 and 8 MBit AT45 series devices are recognized) it is tested for valid formatting. In addition to the block status, things such as the write counter are created. The bottom line contains the possible commands. The colors correspond to the keys ESC and F1...F4 and have the following functions:

Return to the main menu
Indicates the assignment status of the file system
Saves all programs to the Dataflash module
Loads all programs from the Dataflash module
Test the dataflash again (eg. after change)



4.1 Info (F1)

The free files/blocks are counted and displayed in an info box.



4.2 Backup (F2)

If a formatted dataflash is connected, the storage space can be managed with the file selection box:



It should be noted that files can be written only on empty slots or on BUP files. The operation can be canceled with the ESC key. Before a file is overwritten, this must be confirmed again with "Y". During backup, all programs are written to a BUP file. In the Fileselect box, the program name of the first program of the 8 slots is always displayed for BUP files.

4.3 Restore (F3)

If it is called and no formatted data flash is connected, an error message is shown. If a formatted Dataflash is connected, the backup to be read can be determined with the file selection box:



It should be noted that only BUP (backup) files can be read. The selected file will be copied into the flash of the controller without further request. The operation can be canceled with the ESC key.
Additional functions can be selected with the left or right CTRL keys, although not all functions are always available (eg. if there is no dataflash module or if it is not formatted).


Deletes a file


Formats the Dataflash module



4.4 Delete (CTRL+F1)

With this function, any file on the Dataflash module can be deleted. The file selection box will be displayed again. If a file is selected, a message appears asking whether the file should actually be deleted. With the ESC key the operation can be aborted.

4.5 Format (CTRL+F4)

Normally a dataflash module should only be formatted once. Because when formatting the existing write counter is reset along with it.

5 The configuration menu

The user can change various settings by running the Config program on the main menu screen.





5.1 The assignment of the function keys

The currently active function is shown marked and the selection is made using the cursor up and cursor down keys. The bottom line contains the possible commands, the colors correspond again to the keys ESC and F1...F4 and have the following functions:

Leave config page without saving the changes
Change selected setting
Save settings and reboot





5.1.1 Exit (ESC)

This button discards the current settings and returns to the main menu.

5.1.2 Change (F1)

Each time the button is pressed, the currently selected setting changes.

5.1.3 Serial speed

The speed of the serial interfaces (1, 2) can be switched between different bps settings.

5.1.4 I2C speed

Here, the speed of the I2C interface can be switched between 100 and 400 kHz. Most I2C devices handle 400kHz, for compatibility reasons the slow speed can be used.

5.1.5 SPI speed

Here, the speed of the SPI interface can be switched between 156 kHz and 5 MHz.

5.1.6 EEPROM address

This allows to set the EEPROM address to be used with the data EEPROM (XPOKE/XPEEK commands).

5.1.7 End of line

This key can be used to specify the type of line end for the serial and parallel interface. LF only (Unix/Linux), CR only (Mac) and CR+LF (Windows) are possible.

5.1.8 Serial Interface - Type

This option is used if, you want to use a different RS232 level converter than the one provided with the CB2 micro, or if you connect UART devices to it. "Simple" uses the original charge pump based circuit (RS232 compatibility). When "Standard" is set, RX and TX are working like any other UART (TTL). You would normally want to set this to "Simple" whenever you connect a device to the RS232 (DSUB9) port and to "Standard" when you want to use the TTL UART PADs on the PCB.

5.1.9 Serial interface - input pin

Since the original wiring of the serial interface already occupies the TX1 pin (PD3) of the ATMega644P, there is the possibility to switch the input pin of the serial system interface between PD1 (necessary for the CB2 micro) and PD3 (compatibility mode). Switching is possible but note that the CB2 micro's second serial interface can not be used in compatibility mode. You would normally set this to PD1.

5.1.10 Autostart

If no key is pressed when the micro boots up in the intro screen, a program can be set to be started automatically with this option. One of the programs (1...7) can be set to be auto-executed on boot. The auto-start option can be deactivated from this menu as well. This function is useful when you only want your auto-executed program to run upon boot of the system. This ensures unattended execution of this particular program on every reboot.

5.1.11 Save (F2)

This button saves the current settings and reboots to reinitialize the system.

6 The fullscreen editor



The BASIC programs are written with a simple fullscreen editor. The current cursor position is saved in the EEPROM when leaving the editor, separately for each of the 8 programs. As a result, after a system update (relaunching the controller), the cursor may be somewhere within the text area. With left or right CTRL and Home however, it can be quickly put back to the starting position (first character of the first line). If the computer is switched on or if the program is loaded from the Dataflash or copied from another program location, the cursor coordinates are set to the beginning of the program. If the program name begins with an underscore, the program is saved as plain text. Although such a program can not be executed, this function can be used to save pure text files. These texts can then be accessed, for example, by means of EPEEK from address 3072. At the top of the editor the program number (1-8) and program name is displayed. As soon as the text in the program is changed, a star symbol appears in the upper left corner, to indicate an unsaved program. Underneath there is a colored status line in which, for example, errors are displayed. The position of the cursor is indicated by an inverse flashing character. In the program text area, as characters are typed in, the cursor moves to the right. The cursor keys move the cursor in the text field, the page up/down keys move the cursor up/down 8 lines. If necessary, the text is scrolled. The bottom line shows 5 color fields. These correspond to the keys ESC and F1...F4 and have the following functions:

Cancel without saving
Change the program name
Saves the program in internal flash, in the current slot
Reloads the program in the current slot from the internal flash
Starts the program


The keys F1 to F4 have a secondary function if the left or right CTRL key is additionally pressed. The text in the 5 color fields changes accordingly:


Printout of the listing via the printer (LPT) interface
Transmit of the program via the serial interface
Receive of a program via the serial interface
Deletes the program (all lines empty)


For most functions, a confirmation prompt appears in the status line, which must be answered either with (Y)es or (N)o (alternatively with ENTER or ESC).


6.1 Special key functions

The following keys/shortcuts have special functions:


Cursor keys Move the text cursor within the lines (horizontal) or between the lines (vertical).
Page Up Moves the text cursor up 8 lines or all the way up to the top line 1 if keep pressed.
Page Down Moves the text cursor down 8 lines or all the way down to the bottom line 95 if keep pressed.
Home Sets the cursor to the first character of the current line.
CTRL + Home Sets the cursor to the first character of the first line.
End Sets the cursor to the last character of the current line.
CTRL + End Sets the cursor to the first character of the last line.
DEL Deletes the character under the cursor, characters to the right of the cursor are shifted to the left.
Backspace Deletes characters to the left of the cursor, characters to the right of the cursor are shifted to the left.
ENTER It jumps to the beginning of the next line.
TAB Spaces are inserted so that the cursor moves in the editor by 3 characters. Useful for indents in the program text.
ALT + Insert A line is inserted at the current cursor position. All lines from the cursor position move downwards, the last line in the program (95) is lost!
ALT + Delete The line of the current cursor position is deleted. All lines below the cursor position move up, an empty line is added at the bottom of the program (95).
CTRL + C The current line is copied to the buffer. This is indicated by a BUF=line number in the upper right corner of the screen.
CTRL + X The current line is moved to the buffer and deleted. This is indicated by a BUF=line number in the upper right corner of the screen.
CTRL + V The buffer is copied to the current line. This line will be overwritten. The buffer indicator on the top right disappears.
CTRL + F Activates the search function, description in the next section.


6.2 The search function

A search function is integrated into the editor. This allows short text strings (maximum 16 characters) to be searched within the current program. The search is case-sensitive. The search is called up with the key combination CTRL+F. The color of the status bar changes to blue and next to the text "FIND:" the search string can be entered. A white rectangle marks the current end of the search string, corrections can be made with the backspace key.



With the ESC key the search is aborted, an abort occurs even if the search string has a length of 0. After typing the search string, the search can be initiated with the Enter key. The search starts from the current cursor position. After line 95, the search continues back from line 1. If the search string is found, it is displayed inverted in the program text and the cursor is placed at the beginning of the found string.



The ESC key can be used to abort the search; the Enter key is used to start a new search beginning from the current cursor position. As long as you keep pressing the Enter key, the search for the current string continues.

7 Serial program transfer

To transfer files from the CB2 micro to the PC and vice versa, you will need a null modem serial cable. In that case J2 and J3 must be shorted onto the PCB. Alternatively, you can use an ordinary serial cable (not null modem) and short J4 and J5 instead on the PCB. The settings in the config page program of the CB2 micro should be:

Serial speed: 1200 (1) or 2400(1) - the same speed must be set on the terminal program on your PC.
Serial In/Out: simple
Serial Input: PD1


7.1 Communication parameters Standard interface

The following should be set on the PC for the functions of the serial interface
8 bits --- 2400 bps (or 1200) --- no parity --- 2 stop bits --- flow control none
For a program listing transfer from inside the editor, normal text transmission is used, otherwise the X-modem protocol is used. Under Windows you can eg. use the hyperterminal, under Linux the minicom or the script chiptrans.pl in the Tools folder of the source. The last line in your program, must contain a "#" as the first character in that line, when the program is to be transfered. The program uses as interface the /dev/ttyS0, if using another interface the script must be modified accordingly.
Usually, you would want to use the communication parameters in the standard interface on the CB2 micro, to transfer files to and from the PC.


7.2 Communication parameter extended interface

The following should be set on the PC for the functions of the serial interface
8 bits --- 38400 bps --- no parity --- 1/2 stop bits
--- flow control none
For a program listing transfer from inside the editor, normal text transmission is used, otherwise the X-modem protocol is used. Under Windows you can eg. use the hyperterminal, under Linux the minicom or the script chiptrans38.pl in the Tools folder of the source.  The last line in your program, must contain a "#" as the first character in that line, when the program is to be transfered. The program uses as interface the /dev/ttyACM0, if using another interface the script must be modified accordingly.

7.3 Sending to the CB2 micro (BASIC program text)

This procedure is used when you are inside the editor and you want to receive a program from the PC.
  1. Select RECV (CTRL+F3) in the EDITOR and confirm with "Y"
  2. Start the transfer on the PC with ./chiptrans.pl -w file name or from the Hyperterminal (or other terminal program) in Windows.
  3. The program is displayed on the editor, the transfer status is displayed on the PC

7.4 Receiving from the CB2 micro (BASIC program text)

This procedure is used when you are inside the editor and you want to send the program to the PC.
  1. Start the transfer on the PC with ./chiptrans.pl -r file name or from the Hyperterminal (or other terminal program) in Windows.
  2. Select SEND (CTRL+F2) in the EDITOR and confirm with "Y"
  3. The transfer status is displayed on the PC
In addition to the program transfer from within the editor, in which plain text is transmitted, there is also the possibility in the main menu to transfer programs in binary format. The transmission takes place via X-modem protocol. This way, native AVR programs can also be sent and received, which can not be edited with the editor after all.

7.5 Send to the CB2 micro (binary files)

This procedure is used when you are in the main screen (desktop) of the CB2 micro and you want to receive a program from the PC.
  1. Start X-Modem Transfer (send) on the PC
  2. Select the program slot in the main menu
  3. Press RECV (CTRL+F3)
  4. A message box "Data transfer..." is displayed
  5. The CB2 micro screen is periodically switched off during transmission, the status of the transfer is displayed on the PC
  6. The process can be aborted with the ESC key

7.6 Receiving from the CB2 micro (binary files)

This procedure is used when you are in the main screen (desktop) of the CB2 micro and you want to send a program to the PC.
  1. In the main screen, select the program slot to be sent
  2. Press SEND (CTRL+F2)
  3. A message box "Data transfer..." is displayed
  4. Start X-Modem Transfer on the PC (receive)
  5. The status is displayed on the PC
  6. The process can be aborted with the ESC key


7.7 Use of the screenshot function

For the screenshot the script screenshot.pl can be used in the tools directory of the source. It needs ImageMagick and it is called with "./screenshot.pl filename.extension". Then the screenshot function can be triggered on the CB2 micro with the right CTRL+P.

By default, the 16-color mode (default on the CB2 micro) is set to be compatible with the 8-color output, but this must be specified before the file name as a parameter -c8. The screenshot in video mode 7 is implemented as a bulk transfer, where the driver ID, the palette and the entire video memory are transferred. By default, settings are set to 2400 bps and /dev/ttyS0 as interface, if necessary, the Perl script must be changed accordingly. For the extended interface of the Mega644P, the script screenshot38.pl is provided, the interface settings correspond to the transfer settings for this interface. An alternative is the program konvert.pl. For example, this converts captured screenshots into image files using a terminal program. The operation is similar to the screenshot program, but the first parameter is the file to be converted.

8 The integrated monitor/debugger

The CB2 micro also includes a small monitor for debugging. It is launched with the key F12 during the program run or with a BREAK statement in the program.

8.1 The main screen

The monitor can be called in all video modes, but only in VMODE 0 (text mode) and in VMODE 5 (128x64) the full functionality is available. This concerns the functions Go, Step and View because the image memory can not be saved when the monitor is called due to the memory requirements in these video modes.



Separated by columns on the top right is the program, the program line and the statement just processed. Including the currently active program line in the source text. Since only 30 characters per line can be displayed, the last 2 characters of the source line may be missing.
This is followed by the display of all variable values ​​in the left part of the screen and the stack to the right of it. Each FOR loop and GOSUB creates an entry on the stack. Under the variable list, the status of the parallel interface is displayed. First the pin numbers (1 corresponds to D0), below that the data direction (I or O) and at the very bottom the current level.
The bottom line contains the possible commands, the colors correspond to the keys ESC and F1...F4 and have the following functions in video modes 0 and 5:

Ends the monitor and triggers a break (exits the program)
Ends the monitor and resumes program execution
Execute the next statement and then return to the monitor
Displays the current output screen, each press of the button returns to the monitor display
Change to the array display



When the monitor is called, the entire image memory must be saved. However, this works only in the video modes 0 and 5, this is simply because the image memory in the other video modes is larger and thus can not be temporarily backed up. Therefore, in all other video modes the keys F1...F3 are locked:

Ends the monitor and triggers a break (exits the program)
Button is locked
Button is locked
Button is locked
Change to the array display



8.2 The Array View



Press F4 to get to the array view from the main monitor screen. The display is hexadecimal but in addition the corresponding characters from the symbol table are displayed. You can scroll through with PgUp and PgDown. The function keys have the following assignment:

Ends the monitor and triggers a break (exits the program)
Selects the previous XMEM Page, after 00 follows FF.
Selects the following XMEM Page, after FF follows 00.
Toggles the character display on and off
Returns to the main monitor screen



9 The communication program CBTerm mini

CBTerm mini is a terminal communication program that allows the CB2 micro to communicate with another CB2 micro, with a PC, with a dial-up modem or any other RS232 serial device. Since it is an important part for the connectivity, it comes pre-loaded on your CB2 micro KIT. There are two modes of operation. In addition, programs can also be transmitted through CBterm mini, via the X-Modem protocol.





9.1 The assignment of the function keys

The bottom line contains the possible commands, the colors correspond to the keys ESC and F1 ... F4 and have the following functions:


Leave program
Change the mode (normal / dialog)
Send a program using the X-Modem protocol
Receive a program via the X-Modem protocol
Empty text window





9.1.1 Exit (ESC)

After a popup dialog of whether to exit the program, the system returns to the main menu.

9.1.2 Mode (F1)

Each time the F1 button is pressed, the current mode setting changes. The current mode is shown in the upper right corner. Each time you change mode, the text window is deleted. There are two modes, normal and dialog. In normal mode, only the received characters are displayed:



In contrast, both the received and sent characters are displayed in dialog mode. The sent characters are green and the received characters red. So this mode can be used as a simple chat between two serial devices.





9.1.3 Send (F2)

With this function, programs can be sent using the X-mode protocol. First, a selection box appears in which the program to be sent can be selected.



Use the cursor keys up and down to select the program slot to be sent, the ENTER key starts the transmission, which is indicated by a small message box. During program selection as well as before the transmission is initiated on the receiver, the process can be aborted with the ESC key.

9.1.4 Receive (F3)

With this function, programs can be received using the X-mode protocol. First, a selection box appears, in which the program slot to be overwritten can be selected. You can not overwrite the CBterm programm itself. If this is attempted, the process is terminated with an alert box.



Use the cursor keys up and down to select the program slot to be overwritten, then the ENTER key to start the reception, which is indicated by a small message box. Before initiating the reception, the transmission on the transmitter side should be first started. During program selection, the process can be aborted by pressing the ESC key.

9.1.5 Clear (F4)

With this key, the text window is deleted and the cursor is placed at the beginning of the window.

9.1.6 Transferred characters

Some keys and transmitted codes have special functions listed in the table below. The line ends, have the value that is set on the configuration page settings.


ASCII code button action
0x08 Backspace Deletes last character, but only until the beginning of the current line
0x0a ENTER Linefeed (depending on the "Line end" setting in the configuration page)
0x0c F4 deletes the text window
remaining <128 Letters / numbers / signs Output characters

The current version of CBterm
(v0.10) does not support colors.


10 The communication program Colterm

Colterm is a terminal communication program written in BASIC, that allows the CB2 micro to communicate through the serial port with another CB2 micro that runs a server program compatible with Colterm, written by the users. Since it is an important part for the connectivity, it comes pre-loaded on your CB2 micro KIT. The advantage of Colterm compared to the CBterm mini, is that Colterm supports transfer of color text and pseudographics as well as sound. The disadvantage is that the data rate can be slower, depended on how you refresh the page, since additional information is being transfered along with every character. Colterm uses a proprietary communication protocol so it is not compatible to "ordinary" terminals. This means that you cannot use it to communicate with a PC or other device or control smart modems etc. For that reason you use CBterm instead. The Colterm client must run on a CB2 micro and the server must be a CB2 micro that is running a server program compatible with Colterm. This server program, be it a game, application or whatever, is supposed to be written by you and must be written to be compatible with the Colterm communication protocol.


Colterm example communicating through RS232 with a server program,
written to output random characters and colors to the screen


In Colterm, text and pseudographics are drawn on the screen in a 22 lines x 30 columns canvas. The communication protocol allows for individual characters to be transferred at every YX position on the screen, no matter if they are transferred in order or not. This property allows for individual characters to be updated (for example during a networked game), without the need to refresh the whole screen by retransmitting the whole screen characters. So despite Colterm has slower data rate, due to the extra information being transferred, this is very much depended on how you reftesh the screen and in fact it might be much quicker in some aspect.

The last remaining line in the canvas, is used for user text input or keystrokes input (~, left, right, up and down arrow keys), when the server expects a user input. If you reach the end of this line when typing, you automatically continue to the beginning of the line again. Characters are sent serially one after the other, as you type them. Backspace, sends a backspace character. You may type as much text as you like, but backspace is valid only for the current line you type in. So for example you cannot erase a character in the previously typed line (which you cannot see). You may terminate the user text input at any time, using the ENTER character. For arrow keystrokes or the character "~", you do not need to terminate each keystroke with ENTER, as this character is set to be transferred automatically after each keystroke. Make sure your server program handles this, based on the section "10.4 Handling transmit/receive priority" below.



10.1 The communication protocol

The table below, explains the communication protocol that is used in Colterm. Server programs written by the users must follow this protocol for data communication compatible to the Colterm.

Communication modeBASIC commands used for transferServer sent data formatNotes
Graphics
SPUT, SGET[YXFBCYXFBC...ENTER[=Start of graphics transmission (91)
Y=Yposition (0-21)
X=X position (0-29)
F=foreground color (0-15)
B=background color (0-15)
C=transfered character  (in HEX or numerical ASCII value)
ENTER=Stop of transmission (234)
Graphics+SoundSPUT, SGET[YXFBCYXFBC...]SS SSS   SS...ENTER[=Start of graphics transmission (91)
Y=Yposition (0-21)
X=X position (0-29)
F=foreground color (0-15)
B=background color (0-15)
C=transfered character  (in HEX or numerical ASCII value)
]=Start of sound transmission (93)
S=transferred note (0-255)
ENTER=Stop of transmission (234)
Pause times between notes are done with WAIT or SYNC commands.

Colterm assumes communication in 1200 baud and this setting is hardcoded with the BAUD 0 command in the program. You may change this to BAUD 1 if you want to communicate on 2400 baud. However, for compatibility reasons with server programs written by other users for Colterm, it is advised not to do so. The 1200 baud has been chosen as default, because data can be transferred through modems or HAM radio, with simple data-to-tone FSK converters.



10.2 Graphics transfer

Every graphics transmission, begins with the character "[" (ASCII value 91). Then a single character data or multiple charactes data is transmitted, until the ending character "ENTER" (ASCII value 234) is received. The format of the data transmission is as follows:

[ Y X F B C ENTER

The second character Y, is the Y position of the character to be transmitted (C) onto the screen.

The third character X, is the X position of the character C onto the screen
.
The fourth character F, is the foreground color that the character C will have.
The fifth character B, is the background color that the character C will have.
The sixth character C, is the character that will be transmitted (in HEX or numerical ASCII value)

Once the transmission has been initiated with the [ character
(ASCII value 91), the five points above, can be repeated for every character to be sent. After the transmission has been initiated, you can terminate it at any point using the end transmission character "ENTER" (ASCII value 234). No character will be printed at the client end if the YXFBC sequence has not been completed, or if it has been terminated at any point with the ENTER character. The SPUT command is used to transmit data and the SGET to receive.



Valid graphics transmission example in BASIC: 

01 SPUT 91,10,15,12,15,$2B,234
This sends the character "+" ($2B) at the position Y=10 and X=15 and the color of the character will be lime (12) in white background (15). Number 91 begins the graphics transmission and number 234 ends it.



Another valid graphics transmission example in BASIC: 
01 SPUT 91,10,15,12,15,$2B,2,14,2,15,$3A,234
This sends two characters, one after the other. The first character is "+" ($2B) at the position Y=10 and X=15 and the color of the character will be lime (12) in white background (15). The second character is ":" ($3A) at the position Y=2 and X=14 and the color of the character will be red (2) in white background (15). Number 91 begins the graphics transmission and number 234 ends it.


Note that since Colterm uses the BASIC, it is slower in handling and processing the received characters than native AVR programs. Depended on how your BASIC server application code has been written when transmitting data, you might be forced to use a few SYNC statements in your transmit code or in between the [YXFBCENTER characters transmission, to give some time for the BASIC code of the Colterm at the receive end to process the characters correctly. There is no strict rule, it is all try and see. If you receive garbage at the Colterm, then use some SYNC statements on your server transmit code, to slow down the transmission. 


For example:
SPUT [ Y X F B C ENTER


Could be split in:
SPUT [
SPUT Y
SPUT X
SPUT F
SPUT B
SPUT C
SPUT 234


Or maybe:
SPUT [
SYNC 1
SPUT Y
SYNC 1
SPUT X
SYNC 1
SPUT F
SYNC 1
SPUT B
SYNC 1
SPUT C
SYNC 1
SPUT 234



10.3 Sound transfer

Along with graphics, sound can be optionally transferred, but not alone. So you cannot transfer a note without previously having transferred one or more graphic characters. Sound (one or more notes) is always transferred at the end of a graphics transfer. Every sound transfer, begins with the character "]" (ASCII value 93). Then a single note data or multiple notes data is transmitted, until the ending character "ENTER" (ASCII value 234) is received, which also terminates the corresponding graphics transfer. To understand better how sound is imported into a graphics transfer, look at the lines below:

SPUT [ Y X F B C ENTER
SPUT [ Y X F B C ] S ENTER
SPUT [ Y X F B C ] S S ENTER
SPUT [ Y X F B C Y X F B C ] S S S ENTER

Line 1 is one graphics character transfer, without any sound.
Line 2 is
one graphics character transfer, followed by a single note S. S is the numerical value of the note to be transferred.
Line 3 is one graphics character transfer, followed by two notes SS. SS are the numerical values of the notes to be transferred.
Line 4 is two graphics characters transfer, followed by three notes SSS. SSS are the numerical values of the notes to be transferred.

The sound transmission is initiated (within the graphics data sequence) with the ] character
(ASCII value 93). After the sound transmission has been initiated, you can terminate it at any point using the end transmission character "ENTER" (ASCII value 234). This will also terminate the corresponding graphics transmission. No note will be sound at the receiver end, and no graphics will be printed if the SS... sequence has not been terminated with the ENTER character. The SPUT command is used to transmit data and the SGET to receive. Note that "pauses" between notes, can be achieved by delaying the note sending at the server with WAIT or SYNC commands. Of course everything, including graphics, is delayed until the note sequence is completed.



Valid note transmission example in BASIC: 

01 SPUT 91,2,10,12,8,$2B,93,50,234
This sends the note with number 50 to the receiver end, after the $2B character. Number 93 (]) begins the sound transmission and number 234 ends it, which also ends the graphics data transmission.



Another valid note transmission example in BASIC: 
01 SPUT 91,2,9,12,8,$2B,2,10,12,8,$2B,93,50,60,234
This sends the note with number 50 and afterwards the note with number 60 to the receiver end, after the two $2B charactes. Number 93 (]) begins the sound transmission and number 234 ends it, which also ends the graphics data transmission.



Yet another valid note transmission example in BASIC: 
01 SPUT 91,2,9,12,8,$2B,2,10,12,8,$2B,93,50
02 WAIT 10
03 SPUT 60,234
This sends the note with number 50 to the receiver end, after the two $2B charactes. Then it pauses for some time and afterwards it sends a second note with number 60 to the receiver end. Number 93 (]) begins the sound transmission and number 234 ends it, which also ends the graphics data transmission.



10.4 Handling transmit/receive priority

Colterm uses a listen-send approach to handle data transfer priority between the two parties, the client and the server. Since both party actions may take a while to complete, a way must be found so that when the server transmits data to the client, the client is prohibited from sending it's own data to the server and vice versa. This is accomplished by switching between listen and send modes at the two parties alternatively.

The transmit/receive flow goes like this:

1. One end is the client and the other is the server. The server must be running already, if the client is to be connected to it, not the other way round.
2. At the very first run of the client, the client automatically sends ENTER to server and switches to listen mode.
3. The server receives ENTER and switches to send mode. Only then it must send data to client. At the end of the data sending, the server sends ENTER to the client and 
switches to listen mode.
4. The client receives ENTER and switches to send mode. Only then it must send data to server. At the end of the data sending, the client sends ENTER to the server and switches to listen mode.

Steps 3 and 4 above, repeat forever.


Note, client sent data is text characters, strings or keystrokes (~, left, right, up and down arrows), but server sent data is graphics and sound, according to communication protocol (section 10.1).
The server processes the client sent data, then it decides what to do with it (your server program procedure, game, etc.), and then it sends the appropriate changes to the graphics grid of the client and sends the appropriate sounds to the client. When text or single characters is to be sent to the server, the characters or text must be terminated with an ENTER, which indicates to the server the end of the client transmission. However when arrow keystrokes or "~" are sent to the server, the ENTER character is automatically appended to these keystrokes and sent to the server.