AN1921 Motorola / Freescale Semiconductor, AN1921 Datasheet - Page 10

no-image

AN1921

Manufacturer Part Number
AN1921
Description
AN1921 General DSP568xx Interface Examples using the Embedded SDK
Manufacturer
Motorola / Freescale Semiconductor
Datasheet
Interfacing to Serial Devices Using the SPI Port
10
/*
}
In this set-up for the TLC2543 Vcc = REF+ = Vs. This
implies that max. voltage is V ~ ADC no. of bit = 2ˆ12
= 4096. The ADC delivers a count (Vcount) between 0 and 4096.
This allows the above expression to be written as
for(
{
static Word16
SpiParams.bSetAsMaster = 1;
SPIMaster = open( BSP_DEVICE_NAME_SPI_0, 0, &SpiParams );
/* Set bit clock rate so sampling rate */
ioctl( SPIMaster, SPI_PHI_DIVIDER_32, NULL );
/* Set Data format for 16 bit */
ioctl( SPIMaster, SPI_DATAFORMAT_RAW, NULL );
/* SS can be left low between successive SPI bytes */
ioctl( SPIMaster, SPI_CLK_PHASE_SS_CLEAR, NULL);
/* TLC2543 is commanded to use analog input 0,
mean = (sum >> 6);
Vcount = mean;
The coded equation is an adaption of an
equation taken from the Integrated Pressure sensor
Tech Note. The equation relates the voltage out
(Vout) with the pressure (P) and (Voltage supplied) Vs.
Rewriting the equation for P yields,
sum = 0;
for ( i = 0; i < 64; i++ )
{
Output data length = 16 bits,
Output data format = MSB first, unsigned integer */
/* send command word to TLC2543
write(SPIMaster, &ADcmd, sizeof(UWord16));
/* read input from TLC2543
read(SPIMaster, (UWord16 *)&Datain, sizeof(UWord16));
Datain = Datain >> 4;
/* process sleeps for Tenth of sec */
nanosleep( &OneMillisecond, NULL );
DataStore[i] = Datain;
sum += Datain;
Vout = Vs * (0.009*P - 0.095)
P = (Vout/Vs + 0.095)/0.009
where P is pressure in kPa
;
Interface Examples Using the Embedded SDK
;
)
BaroPress;
*/
/* SPI0 is set as master */
*/

Related parts for AN1921