Software Development

Introduction

In order to provide a starting platform for development of user applications, the demonstration application was developed using the MPLAB environment. This project may be used as a template for the development of new applications as it includes some essential elements for example the interrupt handling and project linking. This project was compiled using the Microchip C18 compiler, currently no other compilers are supported by this library.

Interrupts

As the logger uses a bootloader mechanism, which allows it to update application software direct from the CompactFlash card, the application must operate in conjunction with this code. The overlapping area is in the handling of interrupt routines. High priority interrupts only are used and the high priority interrupt handler must be located at program memory location 0x4000h. An example of how this may be done is part of the demonstration project in the source file main.c. When the project is built this will place the interrupt routine in a known place in program memory, which the bootloader program will call when it receives the interrupt.

Reset Vector

As the application relies on the bootloader for its reset, the beginning of the application must be at a known place in program memory. This has been defined as 0x4000h and is enabled by the inclusion of a pre-compiled file c018i.o. This file appears in the library directory of the sample project and will be linked in by the linker file on project build.

Project Linking

In order to build a new application with the reset and interrupt vectors correctly located, the linker file must select the correct locations in program memory. A sample linker file appears in the sample project in the Linker directory. The sample linker file also includes the library functions which are used by the demonstration application, and which may be used for a new application.

Creating a MPLAB project using the Sample project

To recreate the demonstration MPLAB project the user must first install the C18 compiler and MPLAB Version 6.12.0.0 or newer available from Microchip.

The files required for the sample project can be found in the Sample_Application folder on the Compact Flash card provided with the Space_Logger Launch Kit or down loaded from the SpaceLogger web site download area. Copy the complete directory structure to a suitable location on your PC.

Start up MPLAB.

1. Select Project-> New, a pop-up window requires the name of the project be entered 'Demo_app', and the location which corresponds to the sample project top level directory.

2. Select Project->Set Language Tool locations and check the locations of the Microchip C18 Toolsuite:

MPASM Assembler (mpasmwin.exe) should pick up the MPLAB assembler, eg C:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe

MPLAB C18 C Compiler (mcc18.exe or c18demo.exe) should pick up the compiler executable, either full or demonstration compiler, eg C:\mcc18\bin\c18demo.exe

MPLINK Object Linker (mplink.exe) should pick up the linker, eg C:\mcc18\bin\mplink.exe

Click OK

3. Select Project->Select Language Toolsuite, from the pop up window, use the Active Toolsuite list window to select Microchip C18 Toolsuite and click OK.

4. There will be a small project window, with an empty file structure with headings such as Source files, Header Files etc. To add the necessary source files to the project right click on Source files and select Add files. From the sample project directory Source folder select main.c and parse.c and click OK. To add the necessary header files to the project right click on Header files and select Add files. From the sample project directory Headers folder select all files and click OK. To add the necessary linker file to the project right click on Linker Scripts and select Add files. From the sample project directory Linker folder select app0x4000_lib.lnk and click OK.

5. Select Project->Build Options->Project, in the pop up window fill in the following, Browse can be used to locate the installation location of the C18 compiler, and Sample project directories:

Include Path: eg C:\mcc18\h\ Library Path: eg C:\Temp\Sample_Application\Libs\ Linker Path: eg C:\Temp\Sample_Application\Linker\

The other entries should be left blank.

Select the MPLAB C18 tab, check the checkbox 'Use Alternate Settings' and fill in the window immediately below it with the following: -ms -Oa- -w2 -Ot- -Ob- -sca and click OK.

6. Select Project-> Save Project.

This completes the project set up, you should now be able to open the Output window (View-> Output), and build the project by selecting Project-> Build All. The output hex file should be created in the top level of the Sample Project directory, this should be copied to the UPDATE directory and the filename checked to ensure it is in capital letters: DEMO_APP.HEX. prior to uploading.

If you are using a more recent version of C18 than v2.00 you may find it necessary to up date the p18f6620.h header file.

NEXT -->

START