PIC32 with BASIC
Posted by Jim on April 03 2009 17:52:39
It has been a while for this update but there has been a lot of activity in the background -- Coming soon a PIC32 bit microcontroller board with built in fully functional BASIC and an SD Card interface that acts as a disk drive. The main interface is USB from which it derives its power but this can be disconnected and then run as a stand alone device. The board is similar in size and price to the very popular BV511...........
Extended News
This single small (86 x 34mm) board has an on board micro SD card with various options for connectivity. One of the options comprises 4 off 2x8 way sockets that can be plugged into a prototype board, the sockets are laid out in a standard 0.1 matrix so a peg type board can be used for prototyping. The PIC is the PIC32340F512 that has 32k of RAM and 512K of Flash plus all the usual AtoD, ports, timers etc. As well as the main connector there is a separate I2C connector a separate COM port connector (IASI) and a separate SPI connector that has the outputs for a second SD Card. The BV410 SD card holder will simply plug into it to give both drive A: and B: The board is designed to operate up to 2,000,000 Baud but by default comes with a lower Baud rate which can be changed by the user.

The board comes with boot code so that it can be programmed from the USB, there is no need for a special programmer although if you like it can be programmed with a PICkit 2.

The Software

There are three sections of software: the Boot, the BIOS (called Micro-BOS) and the Application BV-Basic.

The Boot

The purpose of this code is to provide a method of re-installing the Micro-BOS should it get erased or damaged in some way without the need of a specialised programmer, it can simply be done through the USB and downloading the Micro-BOS as a hex file. If a PICkit 2 is available then there is also a programming interface for that so the boot will not be required.

Micro-BOS

This started out as an operating system so that the application could easily be ported over to other devices without too much trouble. It has ended up as mainly the Disk, or more correctly the SD Card operating system. All calls to the BOS are through a single address and example code in C will be provided so that users can write C applications rather then BASIC applications. The DOS is fully compatible with FAT16 including long file names and subdirectories. This enables the card to be read in a PC as well as in the device. Another important function the BOS has is an Xmodem downloader that allows the rapid download of binary files.

BV-Basic

It has been over 4 years since I retired TCB (Tiny Control Basic) from the 8 bit world of the Atmel. BV-Basic could not be more different as it takes full advantage of the Micro-BOS and 32 bit register set of the PIC running at 80MHz. Some of the features:

Variable types: Character (8 bit), Integer (32 bit), Hex (32 bit) Float (64 bit) and String - variable length. Arrays are also supported up to 4 dimensions.

Line Numbers: None, the unit of this basic is the SUB (subroutine), which can accept local variables and return values.

Register Access: Interactive access to the processors is available so it is possible to see what's going on. Or to set particular registers for special purposes such as Multiple timer or Comparator access.

Scheduling: A subroutine can be placed in a queue and called in the background at intervals, this is a form of multi-tasking and interrupt handling. For example a sub could be written to handle a particular event and take action on it, lets say when a motor reached the end of its travel there is a switch. The switch could be monitored in the background and halt the motor if the switch is closed. The main body of the could would not need to deal with this. Another example would be a keypad; a sub could be written to put the keys in a buffer when a key is pressed, the main code would only need to look at the buffer and not worry about missing any keys.

File Operations: All of the usual fileopen, read and write commands are available as well as DIR, CD etc. for seeing the directory of the SD card and changing directory. Data can also be written and read to a particular position in the file so that a database could be produced.

To get an idea of what a BV-Basic  program look like here is an example

// creates some test files for reading
sub mf(size)
    fn=openfile("test1.txt", 'w')
    writeln$ fn "Test 1 start"
    for j=1 to size
        write$ fn j, *0x0a
    next
    closefile fn
endsub

 

The comment is // and all programs consist of subroutines beginning 'sub'. In this example the sub requires a parameter (size) that will determine the size of the file that is created. Here are some points to note about the above code:

Hopefully this will be available in small quantities at the end of May this year. The software will continue to be developed after release and updates can be provides as binary or hex downloads.