Skip to content

Code and Go

This is one of a series of “Flash Cards” demonstrating different aspects of the Olduino. This one deals with programming.

When I started the olduino project I had visions of using the Arduino IDE with my own compiler(originally Ted Rossin’s). The IDE is written in Java and after a bit of prodding at it I gave up. Someone on the list pointed out Textpad which is an excellent editor and has a toolbar that lets you attach macros to its buttons to do things like run a compiler on the file you’re editing. I used them to set one up for the compiler and one for the loader and hey, presto – an Integrated Development Environment.

One of the enduring legacies to my arduino focus is the use of avrdude. That’s the program normally used to load avr chips from intel hex files. It talks to programmers using a well-defined protocol which is also understood by the bootloader that runs in an arduino. To program the 1802 I adapted an arduino bootloader so that instead of programming itself it would program the 1802: resetting it, putting it into load mode, and stuffing bytes in via DMA. The olduino pretends to be an atmega644 which has a 64K flash memory. In addition to saving me from coding all the stuff associated with reading intel hex files, using avrdude got me a bunch of diagnostic capabilities like reading back the 1802’s ram which was very handy in the early going.

Here’s the video:

Here’s the C code in the video

   print the string "hello World!"
#define putc(x) out(7,x)
#define nofloats
void main()
	printf("Hello World!\n");

and here’s the assembly code:

	 ldi	100
	 phi	15
lon: dec	15
	 ghi	15
	 bnz	lon
	 ldi	100
	 phi	15
loff: dec	15
	 ghi	15
	 bnz	loff
	 br	zero

Textpad is available at

The textpad macro to compile contains the following command:

c:\lcc42\bin\lcc.exe "-target=xr18DH" "-O" "-Wf-g,;" $File

The upload macro contains:

avd57 a

which invokes bat file avd57.bat

mode com9: rts=on >NUL
C:\apps\arduino22\avrdude -CC:\apps\arduino22\avrdude.conf  -u -V -D -patmega644p -cstk500v1 -P\\.\COM9 -b57600 -U flash:w:%1.hex:i %2 %3

The LCC1802 compiler is hosted on google code.

The version of avrdude i’m using is what came with arduino version 022 but the current code would be available here.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: