ATmega USB Bit Whacker

A Complete Forth System!


These boards are from sparkfun.

Header Board for ATMega128 (sku: DEV-00035) and Breakout Board for FT232RL USB to Serial (sku: BOB-00718).

Remove the FT232RL solder jumper at SJ1 and wire VCCIO to VCC (USB is +5V).

FT232 Pin 1 TXD to ATMEGA128 pin 2.

FT232 Pin 5 RXD to ATMEGA128 pin3.

Power ATMEGA128 from USB +5V and GND.


Add a FTDI USB interface to an ATmega running amforth.

Build amforth for ATmega128. This requires AVRASM2, which comes with AVR Studio.

Here are directions for building amforth for the ATMega128 using a Mac.

You could use avra instead of AVR Studio.

Here are some examples for using amforth on the ATMega128.


The Python uploader that is distributed with amforth is described here.


I rewrote the uploader to provide error reports and to allow interacting with the ATmega from the same program before and after uploading.

My uploader :, an amforth shell.


I figured out the prompt match sequences by running :


In [18]:

In [31]: s.write("cold\n")

In [32]: s.readline()
Out[32]: 'cold\r\n'

In [33]:
Out[33]: ' '
In [34]:
Out[34]: '?'
In [35]:
Out[35]: '?'
In [36]:
Out[36]: '\x00'
In [37]:
Out[37]: ' '

In [38]:
Out[38]: '-'
In [40]: s.readline()
Out[40]: '13 10 \r\n'

In [41]:
Out[41]: '>'
In [42]:
Out[42]: ' '
In [43]:
Out[43]: ''


ATmega USB Bit Whacker

The ATmega running forth provides an interpreter. This interpreter talks to a Python application running on the USB host.

Separating the USB to asynchronous serial FT232RL from the ATmega allows placing the FTDI interface at the computer and placing the I/O some distance away using either RS232 or RS485 signaling. Controlling this remote I/O is easily done with Python + pyserial + pexpect.


pyserial and pexpect are easily installed with easy_install.

Here is an example using Python to talk to amforth using the same Python module used for uploading.

Here is a different approach to USB I/O: USB Bit Whacker.


| © 2008 Ken Staton