In theory my library you mentioned should work. As well as the default SPI library that ships with Teensyduino.
Have you tried removing any version of the SPI library that is installed in your <Arduino sketch folder>/libraries/SPI and run it.
It would then grab the one that works from Teensyduino.
Also again it is hard to say as there is no information here on what is not working. So could be wiring issue, could be voltage issue... Could be software issue.
Example wiring, you say:
But on Teensy as well as many Arduino probably including mega: MOSI=11, MISO=12, SCK=13
So maybe pins reversed?
Not sure about power pins, sounds like you have some ranges of voltages which can work on it. But what voltage are you giving it? ... Again I only took a 10 second look at PDF for it. But the Vdd used I believe controls the voltages of any digital pins it uses... So hopefully 3.3v?
Code wise. The library you supplied is doing nothing fancy. However it using the old stuff for controlling SPI... That is it does:
Code:
void adc1262::adc1262_Init()
{
SPI.begin(); // start the SPI library:
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE1); //CPOL = 0, CPHA = 1
SPI.setClockDivider(SPI_CLOCK_DIV8); //Selecting 1Mhz clock for SPI
...
Which I have not played with the setBotOrder, mode, clock divider calls for awhile now. So if I were using it I would do a 10 minute pass through your library and convert it to SPI transaction code.
That is I would probably remove those lines and use something like:
Code:
void adc1262::adc1262_Init()
{
SPI.begin(); // start the SPI library:
adc1262_Reset();
delay(100);
adc1262_Hard_Stop();
delay(300);
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE1));
adc1262_Reg_Write(POWER,B0000000); // Internal reference voltage enabled
delay(10);
adc1262_Reg_Write(INTERFACE,B00000101); //Status byte enabled , Checksum byte is checksum mode
delay(10);
adc1262_Reg_Write(MODE0, B00000000); // Continous conversion mode, Input chop and IDAC rotation disabled
delay(10);
adc1262_Reg_Write(MODE1,10000000); // FIR mode
delay(10);
adc1262_Reg_Write(MODE2,B10000100); //PGA disabled , PGA gain = 1v/v , Data rate =20SPS
delay(10);
adc1262_Reg_Write(INPMUX,B00000001); //AINO and AIN1
delay(10);
adc1262_Reg_Write(OFCAL0,B00000000);
delay(10);
adc1262_Reg_Write(OFCAL1,B00000000);
delay(10);
adc1262_Reg_Write(OFCAL2,B00000000);
delay(10);
adc1262_Reg_Write(FSCAL0,B00000000);
delay(10);
adc1262_Reg_Write(FSCAL1,B00000000);
delay(10);
adc1262_Reg_Write(FSCAL2,B01000000);
delay(10);
adc1262_Reg_Write(IDACMUX,0xBB);
delay(10);
adc1262_Reg_Write(IDACMAG,B00000000);
delay(10);
adc1262_Reg_Write(REFMUX,0x24);
delay(10);
adc1262_Reg_Write(TDACP,B00000000);
delay(10);
adc1262_Reg_Write(TDACN,B00000000);
delay(10);
adc1262_Reg_Write(GPIOCON,B00000000);
delay(10);
adc1262_Reg_Write(GPIODIR,B00000000);
delay(10);
adc1262_Reg_Write(GPIODAT,B00000000);
delay(10);
adc1262_Reg_Write(ADC2CFG,B00000000);
delay(10);
adc1262_Reg_Write(ADC2MUX,0x01);
delay(10);
adc1262_Reg_Write(ADC2OFC0, B00000000);
delay(10);
adc1262_Reg_Write(ADC2OFC1,B00000000);
delay(10);
adc1262_Reg_Write(ADC2FSC0, B00000000);
delay(10);
adc1262_Reg_Write(ADC2FSC1, 0x40);
delay(10);
adc1262_Start_Data_Conv_Command ();
delay(10);
adc1262_Enable_Start();
SPI.endTransaction();
}
I would also update the read data function as well.
Code:
char* adc1262::adc1262_Read_Data() // Read Data function
{
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE1));
static char SPI_Dummy_Buff[6];
digitalWrite(ADC1262_CS_PIN, LOW);
for (int i = 0; i < 6; ++i)
{
SPI_Dummy_Buff[i] = SPI.transfer(CONFIG_SPI_MASTER_DUMMY);
}
digitalWrite(ADC1262_CS_PIN, HIGH);
SPI.endTransaction();
return SPI_Dummy_Buff;
}
If that did not work, I would then check the settings passed in, and maybe try different SPI_MODE and see if that made difference... I would also try higher speed, again my quick look at spec
it appears that SPI could run up to 8mhz...
Hopefully others can give more information