Technical Projects
Home
 

Overview

Hardware

Software

Fabrication

Download

Resources


Software Programming & Communicating with Atmex

 
You'll need some software to program and communicate with Atmex. First you'll need a development environment. Luckily, AVR has a very well supported free development system, from GNU, Atmel, and others. Secondly, you'll need software to download code into the microcontroller, which I have written. Third, you'll want software to communicate with Atmex, which you probably already have.
 

Development Environments

The development environment is pretty much everything involved in transforming code (C, Assembler, BASIC, etc) into machine (HEX) code. Usually included is a compiler, assembler, debugging system, and simulator. Sometimes included is an in-circuit programmer, in-circuit debugger, programmer interface, etc.

The easiest way to get started is to use Atmel's AVR Studio v4 which comes with an assembler. It's also the 'standard' development environment. (As of July '04, this is what I use, as the latest version of the assembler suppots the ATtiny2313)

Also popular is AVR Studio v3.5 which allows you to use third party compilers, such as the free avr-gcc. It doesn't support the ATtiny2313 out of the box, but I'll put up instructions (if it's possible) to get gcc and AVR Studio running with Atmex. (As of July '04, avrgcc does not yet support the ATtiny2313, but it is expected soon)

You can 'roll' your own system using avrgcc, CodeVision, or any other compiler available. The only requirement is that it supports the ATtiny2313 and generates intel HEX files, which should be pretty universal.

 
Programming in the Bootloader
Once you have an Atmex, you'll need to have the chip initialized with the bootloader firmware. Then you will use software such as JAvrProg to download new code onto the board. (You can use any other AvrProg-protocol compatible programming software, but it's much slower (I added some speeded up commands) and some changes must be made to the code. As of July '04, AvrProg does not support the ATtiny2313 anyways.)

When you first buy a microcontroller, it's completely blank. You'll need to program it with the bootloader once. To program the bootloader, you'll need to first download the appropriate HEX file (which depends on whether you want to use the internal 4MHz oscillator, the internal 8MHz oscillator or some other value oscillator). Typical programmers are the STK-500, the PonyProg SI board, AVR-ISP, etc. You can build a PonyProg SI board on a breadboard very easily using the published schematics.

If you're not sure about what oscillator you want, use the internal 8MHz and the 8MHz bootloader.

 
Installing JAvrProg
Once you have the bootloader on, you can use JAvrProg to program, verify and read the program memory.

First verify that you have a recent (1.4 or later) Java runtime environment (JRE). If not, install the latest version for your OS (there are JRE's for MacOS, Linux, BSD, Windows, etc). Also install the JavaComm API libraries which let Java talk to the serial port.

Then download the JAvrProg classes zip and uncompress it into some convenient folder (say, for example, C:\Program Files\JAvrProg and create a JAvrProg.bat file somewhere, like in your start menu or in the desktop. Enter the following into it:
cd C:\Program Files\JAvrProg
C:
java JAvrProg

Where you replace the directory name with whereever you actually placed the files. Now you can double click on the batch file to open JAvrProg.

 
Using JAvrProg
Once you've gotten JAvrProg running, its easy to download code to the Atmex board.

Connect Atmex to your computer via the serial port, then plug in the DC power (either battery or wall wart). Then click on Browse... and select the HEX file to load (a good one to start with is first.hex, which you can download. It blinks the LED.) Press the reset button on the Atmex and click the Program button within 3 seconds. JAvrProg should search all the serial ports for an Atmex, and load the file. If it thinks there is no Atmex, check that you have programmed the chip with the correct bootloader and with the right fuse setting (the 4MHz bootloader with the 4MHz internal clock set), that the serial port is connected, and the board is powered on. (If you connect to the serial port at 19200bps with a terminal program, typing in 'S' should return "AVR2313")

After programming, press reset again. The LED should start blinking rapidly after 3 seconds.

The only important requirement for the code you upload is that the first instruction is a jump to the rest of the user code. If you're writing in assembly, just put
ORG 0x0
rjmp Main
Main:
....

 In the beginning of your code. I think any reasonable compiler will do this too.