Ads1262 data reading with lpc1768

Hi,

I am trying to interface 32-bit, 10 channel ADC-ADS1262 with LPC1768. In one of my previous post, I described the difficulty I was facing in interfacing the ADC. Now, I was able to make the communicate with the ADC. The issue which I am facing right now is I cannot read the converted digital data from ADC. Can anyone support me on this issue?  I am attaching the code below.

(NB:- CS pin tied LOW and START pin tied HIGH permanently.)

// PROGRAM
#include “mbed.h”

//SERIAL PRINT
Serial pc(p13, p14); //TX , RX

//ADC PINS INITIALISATION
SPI adc(p5,p6,p7); // mosi, miso, sck
DigitalOut reset(p28); // reset
DigitalIn drdy(p27);

unsigned int SPI_RX_buff[10];
unsigned int ads1262_rx_data[10];
signed long int uads1262Count=0;

int main()
{
wait(0.2);
pc.printf(“TRIAL ADC PROGRAM - 00001\n\n”);
wait_ms(10);

wait(0.001);
adc.format(8,3);        //8,0   
adc.frequency(1000000); 

reset=0;
wait_us(1);
reset=1;

while(1)
{  
status=drdy;
pc.printf("DRDY            :  %d\n",status);

reset=0;
wait_us(1);
reset=1;

unsigned char reg=0x14;    
unsigned int dataToSend = 0x20|reg; 
adc.write(dataToSend);     //
adc.write(0x00);           //number of registers   

for(int i=0;i<=3;i++)
{
 SPI_RX_buff[i] =adc.write(0x00); 
 pc.printf("DUMMY BUFFER[%d] : %x \n",i,SPI_RX_buff[i]); 
}
         
ads1262_rx_data[0]= SPI_RX_buff[0];       // read 4 bytes adc count
ads1262_rx_data[1]= SPI_RX_buff[1];
ads1262_rx_data[2]= SPI_RX_buff[2];
ads1262_rx_data[3]= SPI_RX_buff[3];

pc.printf("RX_DATA         : %d \n", ads1262_rx_data[0]);
pc.printf("RX_DATA         : %d \n", ads1262_rx_data[1]);
pc.printf("RX_DATA         : %d \n", ads1262_rx_data[2]);
pc.printf("RX_DATA         : %d \n\n", ads1262_rx_data[3]);

 uads1262Count = ((ads1262_rx_data[0]<<24)|(ads1262_rx_data[1]<<16)|(ads1262_rx_data[2]<<8)|ads1262_rx_data[3]);
 
pc.printf("REGISTER        :  %x \n",reg); 
pc.printf("DATA            :  %d \n",uads1262Count); 

}

}

Hello RAJATH_R_VARMA,

  • To make your post easy to read copy&paste the following three (backtick) characters to a new line at the begin and end of your code section ```.

  • I haven’t used the ADS1262 yet but according to the datasheet, chapter 10.1.9 “Serial Interface Connections”, the interface operates in SPI mode 1, where CPOL = 0 and CPHA = 1. So I’d recommend to modify your code accordingly:

//adc.format(8,3);        //8,0
adc.format(8,1);        //SPI 8 bits, mode 1

Hi @hudakz ,

Thanks for your suggestions. I will try to implement three (backtick) characters from my next post. And as you suggested, I changed the clock format. Can you please help me on the code for reading the data from ADC,if possible?Or can you point out where I am going wrong in the code for reading the data from ADC(ADS1262)?

Thank you once again.