Hello Dan,
To generate a sequence of eight clock pulses for the receipt of each returned data byte, a "dummy" byte needs to be written to SPIDR within the SCI module. It so happens that 0xFF is a benign value that does not interfere with the data returned from the sensor. Of course, to return 16 bits of data you would send two dummy bytes in succession.
The basic sequence to read temperature data from the sensor, assuming bi-directional mode -
Set BIDIROE control bit for output.
Set RST line to high.
Send command byte and ignore return.
Set BIDIROE control bit for input.
Send first dummy byte and store returned LS byte value.
Send second dummy byte and store returned MS byte value
Clear RST line to low.
The following function provides a single SPI data byte transfer in both directions, with appropriate testing and clearing of flags within SPISR -
byte SPI_trans(byte val)
{
while (SPISR_SPTEF == 0);
SPIDR = val;
while (SPISR_SPIF == 0);
return SPIDR;
}
Regards,
Mac