Demo

Loading the Demo

Now we have communication with the TLM we may see what can be achieved. Try the following:

As this is the start we do not have many Forth words loaded yet. To help with interactive development any word in the Library may be loaded from the keyboard with REQUIRED. e.g.

Brilliant the TLM can add 1 and 2 to get 3.

All seems to be working so let us jump up to the real thing and try a multi-tasked program with timer driven interrupts.

Type: FLOAD LDEMO (cr)

Unresolved references:

*** No words Unresolved ***

  Statistics:

Last Host Address: $4AE54

Last Target Code Address: $4B2

Last Variable Address: $2E3

Last EEPROM Address: $0 ok

You should see something like this. You may have noticed the top centre of the PC screen flash through several files.

What happened? First we input FLOAD LDEMO. FLOAD is the Forth word for File Load. It takes the next space delimited word in the input string as a file name and tries to interpret the contents. It has the same effect as you typing the file contents at the keyboard. These are ASCII sequential files that only contain ASCII characters. You will notice that no file extension was used, FLOAD assumes .F if non is given. So if you use .F for all your files then you may refer to them by name only.

The file LDEMO.F asks for other files to be loaded to make up the demo program. As each one loads it's path and name appear at the top of the screen.

Running the Demo

Now you have loaded the demo, let's run it. Type:

ABCDEFGHIJ 123456789 ABCDEFGHIJ

ABCDEFGHIJ 123456789 ABCDEFGHIJ

ABCDEFGHIJ 123456789 ABCDEFGHIJ

ABCDEFGHIJ 123456789 ABCDEFGHIJ etc.

The screen should clear and the following appear forever. The result is not too impressive but what is happening is quite interesting. TTY is just a Dumb Terminal that is part of Win32Forth. It accepts serial input and puts it on the screen. There are three tasks, described later, that result in these characters appearing.

The first is called LETTERS, sends the string 'ABCDEFGHIJ' to a 'pipe' (See Pipes). The second NUMBERS, sends the converted number string '123456789' CRLF to the same pipe. The third UART, takes one character at a time out of the pipe and sends it back to the Host. The rate at which the characters come back is controlled by a Timer interrupt running every 111mSecs.

So you see the Target is quite busy. The tasks LETTERS and NUMBERS are endless, they just run and run. UART only runs once and then STOPs. The Timer interrupt AWAKENs UART and it runs once again. So the characters occur at a 111mSec rate.

The funny thing is why do the letters and numbers, that are being put in the same pipe, not get jumbled up and why two sets of letters and only one of numbers with the CRLF after letters and not numbers?

The answers to these and other questions come later. (see Semaphores)

Viewing the Demo

To stop the demo press the ESC key on the PC. Type:

  ?REM (cr)

  <- Mega103 Stack Empty ok

you should see something like this. We now are back to before running the demo.

We have loaded several new words, the only one you have used of so far is GO. IRTC can show you them all in two ways.

Editor - WinView

The first is to use the editor WinView. Type:

The editor screen should appear with the contents of the file LDEMO.F displayed. This is the so called load screen for the demo program. You will see the file names that appeared on the top of the screen during FLOAD, with the word INCLUDE before each. INCLUDE and FLOAD are the same, it is just that the file reads better by using the word include.

The LDEMO.F file does not give us much information about the program, only the files that go to make it up. If you click on the open file icon a file selection window will appear. You may now move from directory to directory and scan the files in each. To find a file just type the first letter of the filename and the first occurrence of that letter will appear. Keep typing the letter until the file required is highlighted. Now press the Enter key to display the file. We may look through the list of files in LDEMO.F to see the program.

Win32Forth - View

The editor has a Browse mode that lets you look at files without being able to alter the contents. So let us use this to examine the word GO from the Win32For console window:

  HOST VIEW GO (cr)

You should now see the editor screen with the cursor flashing on a : before the word GO. This is the definition of the word that we have just run. The file it is in, shown at the top of the edit screen, is not LDEMO.F that we loaded, it is INIT.DEM. The path is \WIn32for\AVR\DEMO. How did we get here?

Now we will see one of the most useful features of Win32Forth, viewing. When a word is defined a link is generated to the position inside the file from whence it came. When we VIEW, the word is found and the link used to show the file in the place the word was defined.

We may now navigate around the Source files to see how the demo was programmed.