SPI_read

Hi,

in an example sketch named "LTC2400 24 Bit ADC Test" the author uses a function named SPI_read, that does exactly what I need, but the arduino 16.8 compiler tells me, that "SPI_read is not declared in this scope". Of course I inluded SPI.h, but I keep getting the same error message.

Any ideas?

greetings karlsilence (which is a very crude translation of my hometown´s name)

Of course I inluded SPI.h

In what? You need to post your code.

The SPI class has a method called read(). Perhaps that was supposed to be SPI.read().

Or maybe the function in question was written in that sketch in which case you'll need to rewrite it in your sketch.

//TDC7200 tryout

#include <stdio.h> // include the stdiolibrary:
#include <SPI.h> // include the SPI library:

// PINs deklarieren:
const int TDC_CS = 10; //LO-active
const int TDC_ENA = 9; //HI-active
const int TDC_INT = 8;
const int TDC_TRIG = 6;

void setup()
{
// set the slaveSelectPin as an output:
pinMode(TDC_CS, OUTPUT);
pinMode(TDC_ENA, OUTPUT);
pinMode(TDC_INT, INPUT);
pinMode(TDC_TRIG, INPUT);
Serial.begin(9600);

// initialize SPI:
SPI.begin();
}

void loop()
{
digitalWrite(TDC_ENA, LOW);
delay(10); //
digitalWrite(TDC_ENA, HIGH);
delay(10); //

{
// take the SS pin low to select the chip:
digitalWrite(TDC_CS, LOW);
// send in the address and value via SPI:
SPI.transfer(64); //dezimal!
SPI.transfer(01); //dezimal!
// take the SS pin high to de-select the chip:
digitalWrite(TDC_CS, HIGH);
delay(100); //

//24 Bit Register read

SPI.transfer(16); //dezimal! TIME1-Register (Fig.32)

{

long int ltw=0;
byte b0 = 0;

b0 = SPI_read();
ltw |= b0;
ltw <<=8;

b0 = SPI_read();
ltw |= b0;
ltw <<=8;

b0 = SPI_read();
ltw |= b0;
//ltw <<=8;

Serial.print(ltw);
}

}
}

Delta_G:
Or maybe the function in question was written in that sketch in which case you’ll need to rewrite it in your sketch.

Spot on Delta, the function is as follows

byte SPI_read()
{
 SPDR = 0;
 while (!(SPSR & (1 << SPIF))) ; /* Wait for SPI shift out done */
 return SPDR;
}

I have two hometowns but he one in the UK translates to ‘Dogs toilet’

So SPI_read() is equivalent to SPI.transfer(0); Just change the three occurrences of b0=SPI_read(); to b0=SPI.transfer(0);