A simple Turbo C program (Listing 1) running in DOS mode effects the data-transfer cycle in the PC, whereas the transfer is automatic in the chip upon reception of SCK. The routine reads a low byte and a signed high byte and creates a floating-point value by simply adding the low byte, divided by 256, to the high byte.
In the highest resolution mode, which this design uses, a data read can occur only every 1.2 sec, and you should adjust the timing loops accordingly. You may also need to adjust the settling time, DELTIME, depending on the speed of the PC you use. The sample program prints the bytes transferred as well as the temperature, and you can easily modify it.
The data sheet explains the use of the configuration register and changes to make if you need a higher data rate with lower resolution. Click here to download Listing 1. The data transfer takes place beginning with the write of an address byte to the chip's SDI in the order A7 to A0 (high bit to low bit).
If A7 is high, a write takes place; otherwise, a read occurs. For a write, D7 to D0 route to the chip's SDI. For a read, D7 to D0 are available on the chip's SDO. The program always uses both SDI and SDO and ignores whichever it doesn't need. For example, data goes to the chip's SDI even during a read, but the chip ignores this data. Each byte transfers as 8 bits, and each transfer involves the following steps: The PC raises D1/SCK and places 0 or 1 on D2 for the chip's SDI. The PC then reads PAPER. Finally, the PC drops D1/SCK.