This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADS1259: not getting SPI data from ads1259

Part Number: ADS1259

this is the code i have written for stm32f407VG in microC compiler for SPI communication with ads1259 . i have checked clocks for sck,mosi , chip select all are working fine except MISO. i am not getting ant data on miso pin. please some one help me.

void ads1259_init(void);
void ads1259_reset( void);
long read_adc_value( void);
void ads1259_reset( void);
long adc_voltage;
long adc_value[3];
long nativeInt;
long adcval;
long value;
char __buffer[20];
//void Soft_UART_String(char *string_ptr);
//long adc_value[2];
void UART2_Write_Int(long num);
int i =0;
void main()
{
SPI3_Init_Advanced(_SPI_FPCLK_DIV8 , _SPI_MASTER | _SPI_8_BIT | _SPI_CLK_IDLE_LOW | _SPI_FIRST_CLK_EDGE_TRANSITION | _SPI_MSB_FIRST | _SPI_SS_DISABLE | _SPI_SSM_ENABLE | _SPI_SSI_1, &_GPIO_MODULE_SPI3_PC10_11_12);
Delay_ms(300);
UART2_Init_Advanced(9600,_UART_8_BIT_DATA,_UART_NOPARITY, _UART_ONE_STOPBIT,&_GPIO_MODULE_USART2_PD56);
GPIO_Digital_Input(&GPIOA_BASE, _GPIO_PINMASK_2);
GPIO_Digital_Output(&GPIOE_BASE, _GPIO_PINMASK_15); //led1 for drdy
GPIO_Digital_Output(&GPIOE_BASE, _GPIO_PINMASK_8 ); /// chip select
GPIO_Digital_Output(&GPIOE_BASE, _GPIO_PINMASK_12); //led1 for chip select
Delay_ms(300);
UART2_Write_Text(" initializing SPI3 ");
Delay_ms(500) ;
ads1259_init();
ads1259_reset();
ads1259_init();
UART2_Write_Text(" initilization done ");
Delay_ms(500) ;
while (1)
{
GPIOE_ODR.B15=1;
adc_voltage=read_adc_value();
UART2_Write_Text(" adc_voltage = ");
UART2_Write_Int(adc_voltage);
UART2_Write_Text("\r\n");
GPIOE_ODR.B15=0;
}
}

void ads1259_init(void)
{
GPIOE_ODR.B8=0; //chip select low
SPI3_Write(0X11);
SPI3_Write(0X40);
SPI3_Write(0X08);
SPI3_Write(0b10000101);
SPI3_Write(0b00010000);
SPI3_Write(0b00010000);
SPI3_Write(0b00000000);
SPI3_Write(0b00000000);
SPI3_Write(0b01000000);
GPIOE_ODR.B8=1; //chip select high
}
void ads1259_reset( void)
{
GPIOE_ODR.B8=0;
SPI3_Write(0X06);
GPIOE_ODR.B8=1;
}
long read_adc_value( void)
{

GPIOE_ODR.B8=0; //chip select low
SPI3_Write(0x08); //start
Delay_us(100);
SPI3_Write(0x12); //Rdata
adc_value[0]=SPI3_Read(0x00);
adc_value[1]=SPI3_Read(0x00);
adc_value[2]=SPI3_Read(0x00);
Delay_ms(100);
GPIOE_ODR.B8=1; //chip select high
adc_value[0] = adc_value[0]*65536;
adc_value[1] = adc_value[1]*256;
adcval = (adc_value[0] | adc_value[1] | adc_value[2]);
if (adcval & 0x800000)
{
adcval = ~adcval;
nativeInt = adcval + 1;
nativeInt = nativeInt;
value = -((nativeInt*2.9802326E-7)+5);

}
else
{
nativeInt = adcval;
value = nativeInt*2.9802326E-7;
}
return value;
}
void UART2_Write_Int(long num) // Transmit integer value in ASCII format
{
LongToStr(num,__buffer);
UART2_Write_Text(__buffer);
}

  • Hi Saket,

    Welcome to the TI E2E forums!

    Are you able to read registers or get any response from the device?
    I would double check the device's power supplies and ensure that the ADC clock (or crsytal) is working on XTAL1/CLKIN.

    After looking through your code, I see three potential issues:

    1. In the "SPI3_Init_Advanced()" function you appear to be configuring the SPI to MODE0 with the "_SPI_CLK_IDLE_LOW" and "_SPI_FIRST_CLK_EDGE_TRANSITION" arguments. The ADS1259 operates in SPI MODE1, so you may need to use "_SPI_SECOND_CLK_EDGE_TRANSITION" instead.

    2. After starting ADC conversions you only appear to wait 100 us before sending the RDATA command. With the 10 SPS data rate and SINC2 filter, you will need to wait at least 200 ms before reading out the data.


    3. When check if the data is negative, I think instead of inverting of all the bits you just need to sign-extend the 24-bit data into the 32-bit data type. For example:
    if (adcval & 0x800000)
    {
        nativeInt = (0xFF000000 | adcval);
        value = (nativeInt*2.9802326E-7);      // CORRECTION: No additional negative sign is needed here
    }

     

    It would also be helpful if you could share a schematic and let know what frequencies you're using for the ADC clock and the SPI SCLK.

     

    Thanks and best regards,
    Chris

  • . thank you for reply chris,

                     Main frequency is 120 MHz and SPI clock frequency is 3.7 MHz.  will change the SPI mode to 1 from 0 and update here soon.

  • Thank you sir. I have changed spi mode and now my code is working perfectly.

  • Hi Saket,

    Great, I'm glad that fixed the issue! Let us know if you run into any other issues you need help with.

    Best regards,
    Chris