Hai,
I am trying to interface 32-bit 10 channel ADC -ADS1262. I am facing an issue with the MBED code for interface. ADS1262 is interfaced using SPI protocol. Initially, I am able to read the default register values from the ADC. But when I reset my MBED MC, the value changes and some randon values are coming, After 7 or 8 reset consecutively, the accurate value is again obtained. I can't understand the reason for this issue. Can anyone help me with this issue? Where should I make some changes - Hardware part or Software part? I am sharing my code and the serial window here.
//CODE
#include “mbed.h”
//NEXTION DISPLAY
Serial device(p9, p10); //TX , RX
//SERIAL PRINT
Serial pc(p13, p14); //TX , RX
//ADC PINS INITIALISATION
SPI adc(p5,p6,p7); // mosi, miso, sck
DigitalOut cs(p8); // chip select
DigitalOut start(p11); // start
DigitalOut reset(p28); // reset
DigitalIn drdy(p27);
int main()
{
pc.printf("TRIAL ADC PROGRAM \n\n");
wait_ms(10);
wait(0.001);
adc.format(8,3); //8,0
adc.frequency(1000000);
int status=drdy;
pc.printf("DRDY : %d\n",status);
while(1)
{
status=drdy;
pc.printf("DRDY : %d\n",status);
unsigned char reg=0x04;
unsigned int dataToSend = 0x20|reg;
adc.write(dataToSend); //
adc.write(0x00); //number of registers
unsigned int data1=adc.write(0x00);
unsigned int data2=adc.write(0x00);
wait_ms(1);
unsigned int data=data1<<8|data2;
pc.printf("REGISTER : %x \n",reg);
pc.printf("DATA1 : %x \n",data1);
pc.printf("DATA2 : %x \n",data2);
pc.printf("DATA FINAL : %x \n\n",data);
}
}