RVK-Basic

For Atmel AVR Microcontrollers
 
 

WELCOME!



Looking for an affordable compiler designed for real-time applications? Do you want to be able to compile for any AVR processor? Read on.
 

 

Why Basic?


Basic is arguably the easiest computer language to learn and use. You don't have to declare variables (the compiler figures it out for you) and you can write your code either structured or unstructured, however you desire. You can use GOSUB's when speed is of the essence and use CALL's for parameter isolation. You have very full structure control: DO .. LOOP, WHILE .. WEND, IF .. THEN .. ELSE .. END IF, FOR .. NEXT. There are EXIT statements for each type of loop and even a CONTINUE statement. There's also a GOTO. Oh, did I forget to mention interrupts? Well, RVK-BASIC does those too!
 

 

WHY RVK-BASIC?


RVK-Basic was written to make maximum use of the Atmel AVR line of microcontrollers, over 12 different AVR microcontroller types are supported. RVK-Basic allows over 100 types of statements (plus equations). As you will see below these are very well adapted to getting real work done on a micro. Please take a minute to read over the language description below. The statements are first blocked out by type and then described in detail in alphabetical order.
 

 

DO YOU FEEL THE NEED FOR SPEED ?


Speed, you really want speed? What do you mean by speed, speed in writing your code or speed of execution? RVK-Basic is great for both.
 

 

SPEED OF EXECUTION


If you   write a section of code that uses only byte operations (definitely faster   than integers) and if you restrict your variables to register variables instead of RAM, and then use all of the statement types (see below) that do not intentionally slow down the processor (no PAUSE, or SEROUT type statements), you will find that the compiler will generate about 2.2 words of code for each line of RVK-BASIC you wrote. Since the AVR chip is going to execute one word almost every clock tick, you will be executing your BASIC source code at better than 1/3 of the clock frequency of the chip. For example, if the chip clock is 8 MHz you'll be executing more than 2.6 million lines of source code per second !  
 

 

SPEED IN WRITING

RVK-BASIC was written to make it easy to write code and get it right. For example, you're writing your code and you reach a point where to need to set the defrabulator output bit. Now was that on port B pin 2 or was that on port D pin 3? Well, if you used RVK-BASIC that should not be a problem, because when you defined your I/O pins at the beginning of your program you defined a name for that particular bit that you can remember, like:

EQU "B,4", "DEFRAB"

So now all you have to write down is:

SETBIT "DEFRAB"

And you know you got it right the first time. Many more examples could  be   given but just take a look at the language definition below and see for yourself.
 

   

HOW TO BUY A COPY NOW FREE

Free Download

        RVK BASIC for Atmel AVR microcontrollers
        Copyright(c) 1999,2001 by Robert S. Vun Kannon, Jr.
        Revision 021231.0-rvk
		

THE RVK-BASIC LANGUAGE


RVK BASIC for Atmel     AVR microcontrollers, Copyright(c) 1999 by Robert S. Vun Kannon, Jr., Revision 010312.0-rvk

RVK BASIC (RB) is a compiler for Atmel AVR microcontrollers. Currently RB supports the following microcontrollers.

                                                    

         1200, 1200A
         2313
         2323
         2333
         2343
         4414
         4433
         4434
         8515
         8535
         MEGA103 (untested)
         MEGA163 (untested)

          MEGA603 (untested)                                                                                                                                                                                                                               
                   

                     

RB reads a source file written in the RVK BASIC language and produces an  assembler source file which can then be assembled using either of two  free assemblers available from Atmel into executable code for the  microcontroller. The assembler file created is exceptionally easy to  read because it carries the RB source lines in it as comments. RB allows  fully structured flow control and subroutines. Execution speed of the RB  compiled code is phenomenonally fast. If the code uses only byte variables  (in registers) an average of about 2.2 assembler instructions will be
generated for each line of RVK BASIC source code. If a mixture of byte and  integer operations are used in the source code, the compiler will  generate roughly 3 to 4 lines of assembler per line of source code. Since  the AVR processors execute one line of assembler per clock tick, an 8 MHz  processor can execute over 2 million lines of RVK BASIC source code per  second! Sub procedures are available with variable isolation. The use  of these techniques does slow down execution speed somewhat due to the  time required to push and pop values off of the stack. Sub procedures  are not recommended for processors with minimal ram, like the 2313.

Invoke the compiler by:

RB file [/v]

where file is the source file and /v is the option to create a verbose  file. The file must have an extension of ".BAS". The "verbose" switch   will cause the inclusion of some "NOP" statements in order to show all   source code lines. Without this switch some source code lines, like CASE ELSE, which generate no lines of code, will not be present in the  output file. RB will produce an output file with the same name as the  source file and an extension of ".ASM", ready for assembling into  executable code.

The first line of the RVK BASIC code must be a DEVICE statement which  specifies which machine the compiler is to target. The default is an  AT90S1200.

VARIABLES are identified by the last character of their name. They default  to unsigned BYTE variables in registers. Unsigned BYTE variables may also  be specified by suffixing a tilde (" ~") to the variable name, in which case  the byte is stored in static ram. Unsigned INTEGER variables may be  specified in the 23xx and higher chips by suffixing the variable name with %. E.g. X% is an integer while Y is a byte. NOTE: Do NOT use both X%  and X in the same program. In equations byte variables, constants, and  integers may be intermixed provided that the destination is at  least as big as the largest operand. For example, an integer may  be specified as the result of an operation with bytes, integers, or bytes and integers. A byte may be specified as the result only
of an operation with bytes, except for assigning an integer to a byte (see EQUATIONS below).

An array of bytes is named by following the name with @. E.g. TEST@ is a byte array. See DIM, READ, STORE. Arrays are stored  in RAM. A byte in an array is referenced by enclosing the index   within square brackets. NO SPACES ARE ALLOWED FROM THE BEGINNING
OF THE ARRAY NAME TO THE FINAL BRACKET. E.g.
         a@[x] is legal
         a@[ x] is illegal and will generate an error.

A Summary of Variable Types:
       x       byte variable in a register (fastest access)
       x~      byte variable in static ram (slower access)
       x%      integer variable in static ram (2 bytes, unsigned)
       x$      string variable in EEPROM
       x@[]    an array of bytes in static ram.

Many statement types are supported by RB. Only one statement may be put on a line. Line labels must always begin in column 1 of the line. Statements must begin in any column other than 1. If a statement has no line label it must be preceeded by one or more spaces and/or tabs.

The statement set currently supported by RB is as follows. The description of the statements is organized in two blocks. In the first block the statements are given by statement function. Anything included in brackets ([]) is optional. A vertical line symbol (|) is used to indicate that one of two or more possibilities may be used.
In the second block the descriptions are organized in alphabetical order with a description of operation and usage.


The Language by Statement Type

Alphabetical Statement List

RVK-Basic Library

To finish the process of creating object code for the processor, use the AVRASM.EXE compiler. This is available free of charge on the Internet at www.atmel.com under the AVR software section. This compiler is compatable with the code produced by RB. I recommend assembling your code with the following statement:

       avrasm -g -w %1.asm %1.lst %1.rom

where %1 is the name of your program.

You can see more detail about the RVK-Basic language at: