Sample Programs

This program flashes an LED on and off continuously. If you have an Interface Board plugged into the Fox Board then LED P3.3 will flash. If not, then you will need to connect an LED to pin P3.3.

Download the program files: blink_LED.zip


HOOK-UP DIAGRAM


CODE



HOW THE PROGRAM WORKS

In the [device] section, we declare the SNC21030 device. Since there in no audio in this program, we can use the smallest device.

In the [key] section, we set the number of direct inputs to 1. This program runs on its own without any input triggers, but we need always need to declare at least one input.

In the [input_states] section, we define an input state called "locked_out" and we set the P1.0 input to "x". This means that when the "locked_out" input state is set, pin P1.0 will be ignored.

In the [output_states] sections, we define two different output states. One is "led_on" where we declare pin P3.3 as 1 and leave the other P3 pins unchanged, and the other state is "led_off" where we declare pin P3.3 as 0 and leave the other P3 pins unchanged. Setting a pin to 1 outputs a high voltage on the pin, which turns the LED on and setting it to 0 outputs a low voltage on the pin, which turns the LED off.

The [paths] section contains the various routines used in the program.

init: The "init" label always gets called first on power up and on reset. In this program, the init path executes a jump to our "loop" function. The first line in the loop function sets the led_on output state, which turns the LED on. This is followed by a 1.0 second delay. Then we set the led_off output state which turns the LED off. This is followed by a 1.0 second delay. The final command in this routine is a jump back to the loop label and this routine executes again.