EETimes

Embedded Systems October 2000 Vol13_11

Issue link: http://dc.ee.ubm-us.com/i/71842

Contents of this Issue

Navigation

Page 123 of 181

output using an o utpu t d.-iver. Th e va lue is fir t checked fo r valid ity and limited a t the high end. Setting a descrete output 1****** A A A A A A A A A A A A A A A A A A A A A********* * Define an access of a discrete output that is connected to a port on the * micro. The port is written to directly. **** A A A A A A A A A A A A A A A A A A A A A A A A******** I #define SetNAMEStateCA) \ CCA = 0) \ ?PORT1&=-NAMEMASK: PORT1 1= NAMEMASK) void SetNAMEStateC800LEAN state) { if(state = 0) PORT1&=-NAMEMASK; else PORT1 1= NAMEMASK; } Create the input sampling routines Next, create the i~put sampling rou- tines and in terrupt handling routine that are llsed to de termine the value of the inputs. Each routine should sample as many inputs as possible in one func- tion call . The following listings describe examples of some types of inputs and how they can be handled . Listing 5 shows an example where a single digital input port is sampled as a byte and debounced togeth er. If the hardware is designed to optimize this algorithm, e igh t inputs are debounced at one time. The DebounceDi gi ta L routine will take the information from the sample port and the structure to de termine the d ebounced valu e. This structure in cludes eigh t time rs, one for each input port. To sample analog inputs, Listing 6 hows a system tha t navigates a null terminated list o f ana log input defini- tions and fil te rs the inputs. First, all ana log channels a re ampled. The n, fo.- each e ntry in th e input list, the raw va lue is passed to the filter fun ction The most widely deployed embedded database on any planet • • • • Runs on Lin ux, UNIX, Windows, and VxWorks upports thousands of concurrenr users Scales to terabytes of data Survives power loss, application crashes, and hardware failures withollt losing data • • • • www.sleepycat.com 122 oaOBER 2000 Embedded Systems Programming Provides easy-to-llse APIs available from Java, C++, C, Perl, Python, and T cI Links direcdy inro the application: No separate server, no database administrator Small footprint Distributed with complete source code Berkeley DB from Sleepycat Software Phone: 1-877-SLEEPYCAT (to ll-free in the US) or + 1-5 10-526-3972 · Fax: +1-5 10-526-2537

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems October 2000 Vol13_11