Timers, Hello world example – Echelon Mini EVK User Manual
Page 50

output port. This connects the IO10 output to an EIA-232 line driver that is in
turn connected to pin 2 as a serial data output on the RS-232 connector.
// Configure the I/O pins
IO_10 output serial baud (4800) ioSerialOut;
// Send a string to the serial port
const char errorString[] = "String too long.";
void PrintConsole(const char *message) {
if (strlen(message) <= 100) {
io_out(ioSerialOut, message, (unsigned) strlen(message));
} else {
io_out(ioSerialOut, errorString,
(unsigned) strlen(errorString));
}
}
Hello World Example
The following example sends “hello, world” to the serial port on a MiniGizmo
when the device is reset.
#include
#pragma num_alias_table_entries 2
#pragma run_unconfigured
// Configure the I/O pins
IO_10 output serial baud (4800) ioSerialOut;
// Send a string to the serial port
const char errorString[] = "String too long.";
void PrintConsole(const char *message) {
if (strlen(message) <= 100) {
io_out(ioSerialOut, message, (unsigned) strlen(message));
} else {
io_out(ioSerialOut, errorString,
(unsigned) strlen(errorString));
}
}
when (reset) {
PrintConsole("hello, world\n\r");
}
Timers
You can create millisecond and second timers. The millisecond timers
provide a timer duration of 1 – 64,000 milliseconds (or .001 – 64 seconds).
The second timers provide a timer duration of 1 – 65,535 seconds. For more
accurate timing of durations of 64 seconds or less, use the millisecond timer.
These are separate from the two hardware timer/counters used for I/O in the
Neuron core.
To set up a timer, you declare a millisecond or second timer. You can declare
up to 16 timers. To start a timer, you set its value. To execute code when a
timer expires, you create a when task that monitors the timer.
44
Mini EVK User’s Guide