eForth for Atmel AT91SAM7X256 Chip
The series of ARM7 microcontrollers manufactured by Atmel, including
AT91SAM7Axxx, AT91SAM7Lxxx, AT91SAM7Sxxx and AT91SAM7Xxxx, are
interesting for embedded applications because they integrate flash memory, SRAM
memory and hosts of peripherals around the ARM7 core. I have a evaluation board
from Olimex with an AT91SAM7X256 and a 132x132 color LCD display. However,
writing code for this board is a daunting task with conventional IDE tools, as the tools
are just as complicated as the microcontroller itself, which comes with a 671 page
My preferred approach is to bring up a FORTH system first. After FORTH is running, I
have an interactive debugging-programming environment which allows me to
read/write the peripheral registers and to develop application code in very small
modules. For demonstration purposes, I set my goal to display a US flag on the
color display, which is a simple but not trivial task.
SAM7 chips all support a debugging serial UART port called DBGU. Atmel
designed this port to download code into the on-chip flash memory. It is always
active and cannot be disabled. It is the ideal I/O device in a FORTH system to
interact with its user.
I had implemented several FORTH systems for other ARM7 chips. They were based
on the FORTH model eForth, originally developed for 8086 and ported to more than
30 microprocessors. The “e” stands for easy and embedded. This implementation is
named SAM7EF, and the current version is 6.01. It is downloaded to the on-chip
flash memory and executed from there; therefore, it should work on all the
AT91SAM7 chips, although I tested it only on AT91SAM7X256.
The current release consists of two files: SAM7EF.BIN and LCD.TXT. SAM7EF.BIN
is a binary file which is downloaded to the SAM7 chip using the flashing utility SAM-
BA provided by Atmel. LCD.TXT contains FORTH source code to be read by the
eForth system to activate the LCD display and to show the US flag.
By the way, the Nokia 6100 LCD display on Olimex’s SAM7X board contains either
an Epson LCD controller or a Phillips LCD controller. The code in LCD.TXT is for
the Epson controller. If your board has a Phillips controller, you can modify the
code using information provided in the excellent article “Nokia 6100 LCD Display
Driver” by James P Lynch, which I used to bring up the Epson controller.
Want to learn more about eForth?
Want the source code of SAM7EF?
2153 SAM7 ARM7 eForth, C. H. Ting--$25.00
eForth for AT91SAM7X256 MicroConverters from Atmel. It is in ARM7
assembler of Keil uVision3/RealView development suite. It uses the DBGU
serial port to interact with user.. Sample code to display a US flag on
Olimex's SAM7-EX256 Board.
After downloading SAM7EF.BIN and LCD.TXT, the exact steps to bring the Olimex board up and to show the US flag is as follows:
1. Configure HyperTerminal on PC to run at 115200 baud, 1 start bit, 8 data bits, 1 stop bit and no flow control. Remember the COM port number of
the serial UART connector. If your PC does not have a COM port, find a USB-COM converter cable and install it on your PC. Bring up HyperTerminal
and configure it as above.
2. Close HyperTerminal.
3. Connect the DBGU port on SAM7 board to the PC COM port with a UART cable.
4. Install the “ERASE” jumper. Power up SAM7 board for 10 seconds, and power it down.
5. Remove the “ERASE” jumper. Power up SAM7 board.
6. Bring up SAM-BA. In the small dialog window, select the proper COM port, and the correct device ID. I used COM1 and AT91SAM7X256-EK.
Click “Connect” button.
7. In the SAM-BA console, go to the “Send file name” window and browse to the SAM7EF.BIN file. Click “Send file” button.
8. In the “Scripts” window, select “Boot from flash memory” and click “Execute” button.
9. Done with program download. Close SAM-BA.
10. Open HyperTerminal. Change COM port number and configuration parameters if not correct. Go to “ASCII setup” panel, and select 200 ms
delay after sending a line of text.
11. Push RESET switch on SAM7 board, and you should see eForth signs up:
ARM7 eForth, v. 6.01
12. Type “WORDS” and return to see all the commands defined in eForth. Examine the memory and registers using the “DUMP” command.
Examine the data stack using “.S” command. Define new commands.
13. Click “Send text file” option in the “Communication” menu, and select LCD.TXT file. As the FORTH code is sent to SAM7, they are echoed and
scrolled in HyperTerminal console. When the scrolling stops, the US flag is displayed on the LCD display.
AT91SAM7X256 has 64KB of RAM, and it is an ideal platform for my “Firmware Engineering Workshop”. On power-up. eForth is copied to RAM and
executed in RAM with high speed. New FORTH code are compiled and tested interactively in RAM. When an application is fully debugged in RAM,
the code image is copied back to flash memory and a product is produce. I am working to complete this loop. Watch this space for new developments.