R-Engine-D
Chapter 4: Software
4-9
Arguments:
int tm, int ta, int tb, void interrupt far(*t_isr)()
Return values:
none
Both of these timers have two maximum counters (MAXCOUNTA/B) available. These can all be specified
using
ta
and
tb
. The argument
tm
is the value that you wish placed into the
T0CON/T1CON
mode
registers for configuring the two timers.
The interrupt service routine
t_isr
specified here is called whenever the full count is reached, with other
behavior possible depending on the value specified for the control register.
void t2_init
Arguments:
int tm, int ta, void interrupt far(*t_isr)()
Return values:
none.
Timer2
behaves like the other timers, except it only has one max counter available.
4.3.5
Analog-to-Digital Conversion
Parallel ADC AD7852
The high-speed AD7852 ADC unit (U12) is mapped into I/O space starting at 0x0140. To start a ADC
conversion on channel ??, an I/O write, outportb(??,0); will start a new ADC conversion on the
ADC channel ??. The ADC busy signal is routed to IP5 of the SCC26C92. It goes low for 16 ADC clocks
indicating busy. A 16-bit I/O read, inport(0x0140); will return the previous ADC conversion result, with
only upper 12-bit data D15-D4 valid. A sample program
rd_ad12.c
demonstrating the use of the AD7852
is included in
tern\186\samples\rd
. This sample code is already included in the
rd.ide
project in
the
tern\186
directory.
Serial ADC ADS8344
The ADS8344 ADC unit (U14) provides 11 channels of 0-5V analog inputs. For details regarding the
hardware configuration, see the Hardware chapter.
To increase sampling speed on the 16-bit ADC, the necessary operations to read channels have been de-
coupled into three user-defined functions, instead of one function that does everything. This de-coupling
allows for the by-passing of propagation delays of internal control logic, multiplexers, etc.
The following functions will drive the 16-bit ADC. Maximum speed recorded is about 25 KHz, over two
times faster than its earlier 12-bit predecessor. The order of functions given here should be followed in
actual implementation.
unsigned char single_con_byte ( char ch);
unsigned int ad16( unsigned char k );
unsigned int format_data( unsigned int ad);
For a sample file demonstrating the use of the ADC, please see
rd_ad16.c
in
tern\186\samples\rd
.
This sample is also included in the
rd.ide
test project in the
tern\186
directory.
4.3.6
Digital-to-Analog Conversion
Parallel DAC7625
The high-speed DAC DA7625 (U11) is mapped in 0x160 – 0x166.
Use outport(0x0x160, dac); to write upper 12-bit D15-D4 data into DAC channel 1, J3 pin 45