Close

Terminal-BASIC on Arduino DUE with SD card

A project log for Terminal-BASIC

Language interpreter for uC-based systems

Andrey SkvortsovAndrey Skvortsov 11/25/2017 at 13:540 Comments

It seems Terminal-BASIC is ready to be used on Arduino DUE with SPI SD Card interface.

I'v decided to write a short HOWTO about that.

1. Hardware.

I use an Arduino DUE compatible board with SPI SD module and old 128M SD card:


2. Firmware
2.1 Let's download last version of Terminal-BASIC sketch and libraries from sorceforge.
Go to "Files" page, select latest version and download the archive. Now I'am using https://sourceforge.net/projects/terminal-basic/files/r1.1/r1.1rc1/terminal-basic-1.1-rc1-937-arduino-sketch.tar.gz/download.
2.2 Unpack the archive. We'll have some folders: terminal-basic-<VERSION> is a main project sketch directory, others are libraries. FOr now only libsdcard needs to be installed. It is slightly modified version of standard SD library. I removed the dependency of heap management functions. On 8-bit AVR this helps to save reasonable amount of flash. Let's copy libsdcard/SDCard to ~/Arduino/libraries.
THen open sketch in Arduino IDE, select Arduino DUE Programming port board.

2.3 Configuration

Select "config.hpp" file. It contains a list of condition compilation flags of different terminal-basic features. To enable option set it's value to 1, to disable - define as 0.

Default options set is targeted against small 8-bit boards and on DUE we can enable some extra abilities.

I will enable next options:

USE_MATRIX (Darthmouth BASIC-like matrix operations)

SET_PRINTZNES (On ANSI compatible terminals it will set print zones width)

USESD (SD card commands)

Option USE_SAVE_LOAD (SAVE, LOAD CHAIN commands which use internal EEPROM on 8-bit AVR's) should be disabled on Arduino DUE.

On ARduino DUE default BASIC memory size is 65535 bytes (it must be less then 65536). This size can be set in file "config_arduino.hpp" under the "__SAM3X8E__" ifdef branch.

Compile and program the board. After some warnings it should takeoff.

2.4 SD Card preparation.

Here you can download ANSI minimal BASIC test programs and some others.

Copy *.BAS files in root directory under FAT16/32 formatted card.

Insert card and plug the board to PC using Programming port. Connect terminal emulator program, using 115200 baudrate, disable local echo and local line editing - terminal-basic do it for us.

The terminal shopuld look like this upon success:

Let's test it.

Type in a simple program:

10 FOR I%=1 TO 9 : FOR J%=1 TO 9
20 PRINT I%;J%;I%*J%
30 NEXT J%:NEXT I%
40 END

 Input LIST to see it's source and RUN to test. Program can be saved using DSAVE "filename w/o extension" and loaded by DLOAD "filename w/o extension". SD contents list printed on DIRECTORY command. DCHAIN "filename w/o extendion" loads new program, saving old variables.

Discussions