Using the AVR card with BASCOM
The following notes are designed to help get you up and running with your AVR board and the Bascom AVR compiler.
Bascom AVR is an excellent BASIC compiler which is written and maintained by Mark Alberts.
Marc offers a free evaluation version of his compiler – this can be downloaded from his website at http://www.mcselec.com/avr If you like the free version and intend to use Bascom beyond an evaluation period, you should purchase the compiler from Mark (or one of his distributors). It is very reasonably priced.
The AVR board uses a parallel port download cable. One end of the download cable plugs into the 10pin socket marked ‘PSPI’ on the AVR board (this connection is polarised to ensure that you plug in the lead correctly). The other end plugs into the socket marked 'ET-PSPI' (the one furthest from the D-type) on the little PCB which is fitted with a connector to fit into the LPT1 parallel port on your PC. So, connect the cable carefully, but don’t apply power to your AVR board just yet.
Figure 1
The first step is to make sure that you have downloaded the correct variant of the Bascom compiler. There are a few different ones, designed to support different types of microcontroller. So, be sure that you have Bascom ‘AVR’.
Bascom run under Microsoft Windows, the download contains a ‘setup.exe’ and it installs just like any other Windows program. One point to note – Bascom seems to require that the Windows environment has at least one printer installed before it will operate correctly. You don’t actually require to have a printer connected to your PC, just have a printer driver installed.
Start Bascom by running ‘bascavr.exe’. The first thing to do is to configure the programming options to allow direct downloading of programs to the AVR board from the Bascom environment.
From the ‘Options’ menu, select the ‘Programmer’ item. On this panel, there is a ‘Parallel’ tab. One important item on this is the ‘Port delay’ setting. This defaults to ‘0’. A higher number is required for reliable program downloading on a fast PC. In practice, it has been found that a value of ‘10’ works well on a Pentium II PC. If this setting is too low, you will observe error messages when attempting to program your AVR board.
Figure 2
Now choose ‘Universal MCS Interface’ from the ‘Programmer’ drop-down list box. Next, click on the ‘Universal’ tab and select ‘FUTURELEC’ from the ‘Programmer’ drop-down list box.
Figure 3
Click ‘OK’ to save these options.
The first program that we will develop is quite simple. It causes a LED (which we will attach to the AVR board) to flash. This program is named ‘BasLED1.bas’. Download this into a new directory on your hard drive. Check that the file is not marked as ‘read only’.
From the Bascom ‘File’ menu, choose the ‘Open’ item and select the ‘BasLCD1.bas’ file. You should see the program code appear in a new window. Now compile the program, either by using the ‘Program’ menu and choosing the ‘Compile’ item, or by pressing F7.
The code will compile and produce a file name ‘BasLED1.bin’. This contains the code which we want to run on the AVR board.
This program will flash a red LED which is connected to a port pin on the AVR board. First, ensure that there is no power applied to the board. Then, connect a red LED and 470 ohm resistor to the board as described & pictured below.
Connect one end of the resistor to pin 9 (+5V) on the 'SDP8' connector. Connect the other end of the resistor to the shorter lead on the LED. Connect the longer lead of the LED to pin 3 (PB7) on the SDP8 connector. Note that the legend on the AVR board incorrectly shows pin 1 as being on the top right hand side of the connector. It is, of course, on the top left hand side.
Figure 4
We are now ready to load our program onto the AVR board. First, check that the board is still properly connected to your PC. Now apply power to the board.
Next, from the ‘Program’ menu and select the ‘Send to Chip’ item (or press F4).
Check that the ‘Chip’ dropdown listbox shows ‘90S2313’ – this is the type of chip which is installed on the AVR board. If you see an error message, stating that the chip cannot be identified, check that the programming cable is correctly plugged in & review the section “Setting up Bascom”, above.
Now, select the ‘Chip’ menu and select the ‘Autoprogram’ item.
The code will be downloaded onto your AVR board.
Figure 5
The download process should only take a few seconds. As the program downloads, the green LED on the board will flash.
When the download is complete, the program will start to run on your board. The red LED which you connected earlier should flash rapidly.
Congratulations! You have just compiled, loaded and run your first Bascom program.