Software Programming in PicAxe BASIC

You are in home \ microcontroller \ PicAxe \ PicAxe BASIC Programming (back)  

PicAxe pages: Picaxe General   Wiring up the Picaxe   Programming the Picaxe   Projects  
Software

Intro.

Input &
Output

Branching
& Jumping

Looping

Serial
comms.

Picaxe code
to html
converter

   
 

Software Intro - Programming in PicAxe BASIC


Preliminary info...
Currently incomplete...
Software Involved
  • PicAxe BootLoader   The BootLoader & Interpreter that runs your program is already built-in to each Picaxe chip.
  • Programming Editor   Downloaded from Rev-Ed website (free). This puts your program into the Picaxe.
  • User Program   This is the instruction code that you write yourself.

Programmers Reference

Variable space in RAM

W 0 W 1 W 2 W 3 W 4 W 5 W 6
B 0 B 1 B 2 B 3 B 4 B 5 B 6 B 7 B 8 B 9 B 10 B 11 B 12 B 13
                           

B0 to B13 are Byte variables (8 bits), and W0 to W6 are Word variables (16 bits).

The RAM available to the programmer of the '08 is 14 Bytes, or 7 Words, or a combination of these. Note that the Word variables and the Byte variables are overlaid, so writing a word to, say, W 4, results in variable B 8 & B 9 being occupied by the upper and lower bytes of the Word variable.

Also, the first Word (W0) is accessable as 16 bits of bit-memory, with the first Byte (B0) split into the first 8 Bits (BIT0, BIT1, BIT2, BIT3, BIT4, BIT5, BIT6, BIT7) and the next Byte (B1) split into the final 8 bits (BIT8 to BIT15).
W0
B0 B1
BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0 BIT15 BIT14 BIT13 BIT12 BIT11 BIT10 BIT9 BIT8

the use of the keyword symbol is a good idea...



Example code

Let b0 = 3          'assigns the value of 3 to the variable b0  
Let b0 = b0 + 1     'adds 1 to the value stored in b0
debug b0            'shows the value of the variables
The above code sample makes the variable b0 have the value of 3, then adds 1 to it. The debug output window will show all the variables, and that the value stored in b0 is 4.

Now lets show a few more things...
        Let b0 = 0          'assigns the value of 0 to the variable b0  

repeat:                     'this is a label that 'bookmarks' this spot in the program 
        Let b0 = b0 + 1     'adds 1 to the value stored in b0
        debug b0            'shows the value of the variables
        pause 1000          'pause for 1 second (1000 milliseconds)
        goto repeat         'this jumps to the label called repeat
In this example we assign a value of 0 to the variable b0, then repeatedly add 1 to it, displaying the results then pausing a second before repeating everything except the first line.


Interrupts

The Picaxe can nest interrupts up to 4 deep.
Map of RAM allocation and access in Picaxe