The 'hello world' of the embedded programming game - this simple project will just set some lights flashing on the H8 target device. Since it is the first software project here, I have shown detailed steps in creating the project workspace. Future software projects will assume you can do this.

HEW organises your work into projects within workspaces. We will first create a workspace called hewtest which will hold our projects. Open HEW and select Setup | options from the main menu. In the dialog that opens, select the workspace tab. This is where we choose the default folder where future workspaces will be created. You need only do this once. enter a suitable location for the default folder:

Once you have done this, you can create a new workspace in that folder. Select File | New workspace.. from the main menu and enter the appropriate values:

Notice that by default HEW generates a project with the same name as the workspace. Rename the project to blinky1. We will be creating a number of projects in this workspace so give them descriptive names.

You will next be asked to say what processor is to be used. Note that it is not so straightforward to change this later.:

You can select "Finish" at this stage and HEW will generate a number of files for you and select the appropriate header file. There will seem to be quite a lot of them:

However, they have fairly sensible names and you can work out quite easily what each is supposed to do. At this point, you can build the project by pressing F7 or by selecting "Build" from the "Build" menu. Progress can be monitored in the output window at the bottom of the screen. You should see a successful build with no errors and no warnings. Not too surprising as the HEW has generated all the code and really should not get that wrong.

Before going any further, we need to set some build options. Select "Build | Compiler" and click the "list" tab in the dialog. Click on the "generate list file" tick box and ensure that all the options are also ticked.

Select "OK" and open the Linker options dialog by selecting the "Linker" option from the "Build" menu. Again select the List tab and ensure that "generate map file" is selected. This creates a file with information about the size and location of all the symbols declared in your program which can be useful when you are trying to sort out some kinds of problem. It is easiest to get in the habit of turning this on now.

Select OK and now build your project again. There should still be no errors or warnings. If you now look in the output folder (The Debug folder within the project folder) you will see a .map file and a number of .lst files, one for each source module. Have a look at each of these and try to make some sense of what each one contains. You may not be be any the wiser but you may as well find that out for yourself.

Open main.c and you will find it contains a little bit of (useless) code created by the project generator. You can delete everything after the #include line and replace it with the following:

unsigned char count;
int temp;

int main (void)
{
IO.PCR8= 0xFF; // all bits are output
while (1)
{
count++;
IO.PDR8.BYTE = count;
temp = 10000;
while (temp)
{
temp--;
}
}
return (0);
}

This little section of code will just put a constantly increasing binary value out to IO port 8.

If you have left all the other settings at their default value, you will have generated an output file with the extension .mot in the Debug folder of your project. This is the file that gets loaded into the flash memory of the tartget board.

To download the image to the target board, start the FDT in Basic mode and select the output file that you have created.