Step 2: writing the device application, Ft 5000 evaluation boards – Echelon Mini FX User Manual

Page 52

Advertising
background image

Mini FX User's Guide

39

Save. This creates a new empty Neuron C source file named main.nc in your

chosen location, and it opens the file using your computer’s default text editor.

3. Proceed to the next section to write your Neuron C device application in the main.nc

file.

Step 2: Writing the Device Application

When developing the device application, you will typically concentrate on writing the

algorithms that implement your device’s functionality. To do this, you will program any

required interaction between the device application and the I/O devices on your device
hardware. In this step, you will create Neuron C I/O declarations and implement your

desired I/O functionality in the main.nc Neuron C source file that you created in the
previous section. If you are using the Mini FX/FT Evaluation Kit, you will additionally

add code that writes to the LCD on the FT 5000 EVB.
Note: The I/O device declarations used for the Mini FX/FT hardware (FT 5000 EVBs)
and the Mini FX/PL hardware (PL 3150/PL 3170 EVBs) are different. Therefore, follow

the section corresponding with the development platform or platforms you are using for

the appropriate code to use.

FT 5000 Evaluation Boards

1. Enter the following directives:

#include <string.h>
#include <io_types.h>
#include <control.h>

//required to compile Neuron C source code
#pragma num_alias_table_entries 0

//run application even if device is uncommissioned
#pragma run_unconfigured

2. Add the following code that declares the I/O hardware for the SW1 button and LED1

on the FT 5000 EVB (both LED1 and SW1 are connected directly to the I/O 2 and I/O

9 I/O pins, respectively):

IO_2 output bit ioLed1 = 1;
IO_9 input bit ioSwitch1;

3. Add the following code that adds functionality to the Switch and LED I/O:

//Create global variable to store the previous LED state

boolean switchState;

// Function for setting LED1

void SetLed(boolean led1)
{
io_out(ioLed1, !led1);
}

// Read the SW1 button when pressed and then set LED1

void DisplayStatus(boolean led, boolean sw);

when(io_changes(ioSwitch1) to 0)
{
switchState ^= TRUE;
SetLed(switchState);
DisplayStatus(switchState, switchState);
}

Advertising