SD for MSP430 eForth

I decided that it would be nice to have a system where I could use eForth on the MSP430 with a file system. Something like the BLOCK/BUFFER system of figForth. The starting point is the ability to read and write data to a SD card.

While I started testing by writing the SPI routines in high level eForth, I quickly moved this into the system.S file along with the other low level and initialization code. The high level routines are in their own file that gets included at the end of the main assembly file.

SD support

CRC7

At startup SD cards have the CRC7 checking of commands disabled except for a few cases. I expect that I will eventually enable them to protect from errors in transmission although those will hopefully be infrequent. There are two words to support this. One accepts a new byte of data and updates the CRC while the other accepts a command packet and adds the CRC byte.

Virtual Memory

The first Forth that I ever used was fig-Forth. fig-Forth used a virtual memory system which kept a set of buffers into which it would read data from the disk. This seems like a good fit for what I want here. Rather than use the limited SRAM for the buffers, they are placed just below the system vectors. One wrinkle with that is that I set the MPU segment boundary to x0fc00 so that the vectors could be protected from being over written. This makes all memory above that boundary unusable. About 17K that can't be used. Not a problem as of yet. Some additional USER variables are required in addition to the new code:

This is pretty much just a copy of the fig-Forth code. I did eliminate the OFFSET variable since I see no need for supporting multiple drives. It might be handy for splitting up the huge space available but for now I will skip it.

Integration

In order to get eForth to compile text from the disk drive there needs to be a few changes. In fig-Forth that was in the word WORD which checked the BLK variable. If it was non-zero then it read that block into memory otherwise it used the terminal input buffer. eForth doesn't use a word by that name but it has something which does the same thing.

Editors

After getting all of that working I spent some time getting some basic tools working. I wanted an editor and that resulted in a diversion to add vocabulary support. Built in are the basic search order words GET-ORDER and SET-ORDER. The SD card hasa couple of screens that add VOCABULARY and such.

Then I dug up an image from when I ran fig-Forth on a MC68000 and that had two screen editors. The H19 based editor was a non-starter as that used the H19 editing features and its ability to dump the contents of the screen. Not very useful unless you are using a H19. The other was the screen editor written by Henry Laxen and published in the Sep. 1981 issue of Dr. Dobb's Journal.

Before working on that I got the fig-Forth editor working. This provided some basic editing ability so that I wasn't constantly swapping the SD card between the Launchpad and main computer.

Home