English
Language : 

MAX1402_07 Datasheet, PDF (33/38 Pages) Maxim Integrated Products – +5V, 18-Bit, Low-Power, Multichannel, Oversampling (Sigma-Delta) ADC
+5V, 18-Bit, Low-Power, Multichannel,
Oversampling (Sigma-Delta) ADC
8051
P3.0
P3.1
VDD
RESET
MAX1402
DOUT
DIN
SCLK
CS
Figure 14. MAX1402 to 8051 Interface
/* Low-level function to write 8 bits
** The example shown here is for a bit-banging system with (CPOL=1, CPHA=1)
*/
void WriteByte (BYTE x)
{
drive SCK pin high
count = 0;
while (cout <= 7)
{
if (bit 7 of x is 1)
drive DIN pin high
else
drive DIN pin low
drive SCK pin low
x = x * 2;
drive SCK pin high
count = count + 1;
}
}
/* Low-level function to read 8 bits
** The example shown here is for a bit-banging system with (CPOL=1, CPHA=1)
*/
BYTE ReadByte (void)
{
x = 0;
drive SCK pin high
count = 0;
while (cout <= 7)
{
x = x * 2;
drive SCK pin low
if (DOUT pin is high)
x = x + 1;
drive SCK pin high
count = count + 1;
}
}
return x;
Figure 15. Bit-Banging SPI Replacement
______________________________________________________________________________________ 33