eDAC() //Write to 1 analog outpu t.
eDI() //Read 1 digital input.
eDO() //Write to 1 digital outp ut.
eTCCon fig() //Configure all timers an d counters.
eTCVal ues() //Update/reset and read a ll timers and counters.
In addition to the basic operations, these functions also automatically handle configuration as needed. For example, eDO() sets
the specified line to output if previously configured as input.
The first 4 functions should not be used when speed is critical with multi-channel reads. These functions use one low-level function
per operation, whereas using the normal Add/Go/Get method with IOTypes, many operations can be combined into a single lowlevel call. With single channel operations, however, there will be little difference between using an easy function or Add/Go/Get.
The last two functions handle almost all functionality related to timers and counters, and will usually be as efficient as any other
method. These easy functions are recommended for most timer/counter applications.
Following is example pseudocode:
//Take a measurement from AIN3 using 0 -5 volt range and 12-bit resolut ion.
//eAIN (Handle, ChannelP, ChannelN, *V oltage, Range, Resolution,
// Set tling, Binary, Reserved1, Reser ved2)
//
eAIN(l ngHandle, 3, 0, &dblVoltage, LJ_ rgUNI5V, 12, 0, 0, 0, 0);
printf ("AIN3 value = %.3f\n",dblVoltag e);
//Set DAC0 to 3.1 volts.
//eDAC (Handle, Channel, Voltage, Bina ry, Reserved1, Reserved2)
//
eDAC(l ngHandle, 0, 3.1, 0, 0, 0);
//Read state of FIO2.
//eDI (Handle, Channel, *State)
//
eDI(ln gHandle, 2, &lngState);
printf ("FIO2 state = %.0f\n",lngState) ;
//Set FIO3 to output-high.
//eDO (Handle, Channel, State)
//
eDO(ln gHandle, 3, 1);
//Enab le and configure 1 output timer and 1 input timer, and enable Co unter0.
//Fill the arrays with the desired val ues, then make the call.
alngEn ableTimers = {1,1,0,0,0,0}; //En able Timer0-Timer1
alngTi merModes = {LJ_tmPWM8,LJ_tmRISIN GEDGES32,0,0,0,0}; //Set timer m odes
adblTi merValues = {16384,0,0,0,0,0}; / /Set PWM8 duty-cycle to 75%.
alngEn ableCounters = {1,0}; //Enable C ounter0
//
//eTCC onfig (Handle, *aEnableTimers, * aEnableCounters, TCPinOffset,
// Ti merClockBaseIndex, TimerClockDiv isor, *aTimerModes,
// *a TimerValues, Reserved1, Reserved 2);
//
eTCCon fig(lngHandle, alngEnableTimers, alngEnableCounters, 0, LJ_tc750 KHZ, 3, alngTimerModes, adblTime rValues, 0, 0);
//Read and reset the input timer (Time r1), read and reset Counter0, an d update
//the value (duty-cycle) of the output timer (Timer0).
//Fill the arrays with the desired val ues, then make the call.
alngRe adTimers = {0,1,0,0,0,0}; //Read Timer1
alngUp dateResetTimers = {1,1,0,0,0,0}; //Update Timer0 and reset Timer 1
alngRe adCounters = {1,0}; //Read Count er0
alngRe setCounters = {1,0}; //Reset Cou nter0
adblTi merValues = {32768,0,0,0,0,0}; / /Change Timer0 duty-cycle to 50%
//
//eTCV alues (Handle, *aReadTimers, *aU pdateResetTimers, *aReadCounters ,
// *a ResetCounters, *aTimerValues, *a CounterValues, Reserved1,
// Re served2);
//
eTCVal ues(lngHandle, alngReadTimers, a lngUpdateResetTimers, alngReadCo unters, alngResetCounters, adblT imerValues, adblCounterValues, 0 , 0);
printf ("Timer1 value = %.0f\n",adblTim erValues[1]);
printf ("Counter0 value = %.0f\n",adblC ounterValues[0]);
4.3.10 - SPI Serial Communication
The UE9 supports Serial Peripheral Interface (SPI) communication as the master only. SPI is a synchronous serial protocol
typically used to communicate with chips that support SPI as slave devices.
This serial link is not an alternative to the USB connection. Rather, the host application will write/read data to/from the UE9 over
USB, and the UE9 communicates with some other device using the serial protocol. Using this serial protocol is considered an
advanced topic. A good knowledge of the protocol is recommended, and a logic analyzer or oscilloscope might be needed for
troubleshooting.
There is one IOType used to write/read data over the SPI bus:
LJ_ioS PI_COMMUNICATION // Value= numb er of bytes (1-240). x1= array.
The following are special channels, used with the get/put config IOTypes, to configure various parameters related to the SPI bus.
See the low-level function description in Section 5.3.16 for more information about these parameters:
LJ_chS PI_AUTO_CS
LJ_chS PI_DISABLE_DIR_CONFIG
LJ_chS PI_MODE