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: can not read correct data from ads1259,

Part Number: ADS1259
Other Parts Discussed in Thread: ADS1258

i have use hareware spi1 in stm32 to drive the ads1259 chip, the speed of spi is 250KHz.

when i power on the system, i wait 200ms,then  initial the ads1259, and do a reset like this:

//

Hard ware reset mode
void ADS1259_reset(void)
{
ADS1259_Init_Delay(DELAY_TIME_RESET);
ADS1259_RESET_L;
ADS1259_Init_Delay(DELAY_TIME_RESET);
ADS1259_RESET_H;
ADS1259_Init_Delay(DELAY_TIME_RESET);
}

and then send a sdatac command

void ADS1259_INIT(void)
{
ADS1259_Init_Delay(DELAY_TIME_RESET);
ADS1259_reset();
ADS1259_Init_Delay(DELAY_TIME_RESET);

ADS1259_WRITE(CMD_SDATAC);//Stop Read Data Continuous mode
ADS1259_Init_Short_Delay(DELAY_SHORT);
#if 0
ADS1259_WRITE(0X40);//write start from 00h
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X08);//write 9 reg 8+1=9
ADS1259_Init_Short_Delay(DELAY_SHORT);

ADS1259_WRITE(0X05);//00000101 RBIAS + spi timeout
ADS1259_Init_Short_Delay(DELAY_SHORT);
//ADS1259_WRITE(0X01);//00000001 spi timeout
ADS1259_WRITE(0X18);//00011000 SINC2 + EXTREF
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X03);//60sps , gate Convert mode
ADS1259_Init_Short_Delay(DELAY_SHORT);
//OFC[2:0]
ADS1259_WRITE(0X00);
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X00);
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X00);
ADS1259_Init_Short_Delay(DELAY_SHORT);
//FSC[2:0]
ADS1259_WRITE(0X00);
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X00);
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X40);
#endif
ADS1259_Init_Delay(DELAY_TIME_RESET);
}

the while loop, i call function:

void ADS1259_Read_Reg_Enable(void)
{
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(CMD_SDATAC);//Stop Read Data Continuous mode
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X20); //1st opcode, read from address 0x00
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X08); //2dn opcode, read 9 regs value
ADS1259_Init_Short_Delay(DELAY_SHORT);
}

to read the regs value,

but after i flash the chip and run thr mcu,

i get the data below:

ADS1259_REG[0] = 0x25
ADS1259_REG[1] = 0x8
ADS1259_REG[2] = 0xc0
ADS1259_REG[3] = 0x0
ADS1259_REG[4] = 0x0
ADS1259_REG[5] = 0x0
ADS1259_REG[6] = 0x0
ADS1259_REG[7] = 0x0
ADS1259_REG[8] = 0x40

the first data is diff from datasheet(reset value is 10XX0101b), cause i do not write any regs at all.

then i write regs like below:

ADS1259_WRITE(0X40);//write start from 00h
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X08);//write 9 reg 8+1=9
ADS1259_Init_Short_Delay(DELAY_SHORT);

ADS1259_WRITE(0X05);//00000101 RBIAS + spi timeout
ADS1259_Init_Short_Delay(DELAY_SHORT);
//ADS1259_WRITE(0X01);//00000001 spi timeout
ADS1259_WRITE(0X18);//00011000 SINC2 + EXTREF
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X03);//60sps , gate Convert mode
ADS1259_Init_Short_Delay(DELAY_SHORT);
//OFC[2:0]
ADS1259_WRITE(0X00);
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X00);
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X00);
ADS1259_Init_Short_Delay(DELAY_SHORT);
//FSC[2:0]
ADS1259_WRITE(0X00);
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X00);
ADS1259_Init_Short_Delay(DELAY_SHORT);
ADS1259_WRITE(0X40);

the result is all the same ,nothing changed,

i get the data below again:

ADS1259_REG[0] = 0x25
ADS1259_REG[1] = 0x8
ADS1259_REG[2] = 0xc0
ADS1259_REG[3] = 0x0
ADS1259_REG[4] = 0x0
ADS1259_REG[5] = 0x0
ADS1259_REG[6] = 0x0
ADS1259_REG[7] = 0x0
ADS1259_REG[8] = 0x40

could anyone tell me why?

is something wrong in  precedure of Read from Registers and  Write to Register??

thank you verymuch

  • Hi Ming,

    I couldn't find anything wrong in the code that you shared, but sometimes code hides what is actually happening. If you have an oscilloscope or logic analyzer capture of the SPI communication, it would be helpful to see what is happening on the /CS, DIN, DOUT, SCLK, and /DRDY (if you have a 5th channel).

    Are you toggling the /CS pin at all in your code?
    If not, /CS might help to frame the SPI commands to ensure that when you send a RREG or WREG command that you are indeed starting a new command and not continuing a previous RREG or WREG command.

    How long are your delays between SPI bytes?
    With the ADS1259, you shouldn't have to insert additional delays between bytes (within a command). Also, note that if these delays are too long that the /SPI communication may timeout. This is another reason why I'd suggest using /CS. 

    Also, I would recommend using a faster SCLK speed, between 2 and 4 MHz. Occasionally, I have come across some odd SPI behavior when the SCLK frequency is too slow. Also, testing the SPI communication at a different SCLK speed is sometimes a good test to help identify communication issues.

  • hi, Mr, 

    last night ,i had read many question on ti e2e, cause i new to use ads1259.

    and i circuit was designed like below, /cs tied low level, and start tied to low level too, i use freertos and stm32f103 , use hardwre spi to drive the ads1259, use spi mode 1.CPOL =0, CPHA=1.

  • Hi Mr Chris Hall

    the /cs is designed to tied to low level ,is the design correct? 

    i had read the datasheet ,the cs can be designed to tied to GND,

    ADS1259_Init_Short_Delay(DELAY_SHORT) is like below:

    void ADS1259_Init_Short_Delay(DELAY_SHORT)

    {

    for(i-0;i<DELAY_SHORT;i++);

    }

    the stm32F103 main clock is 72MHz,i think the delay will be very short.

    and taday i will try to delete the delay to test ,and use more quick spi speed as you recommend, and any result i get, i will tell you on this post.

    than you very much!!

  • Hi Mr Hall

    There are more questions abouts how to use ads1259

    1, is the ofc and fsc regs needed on my project, if I use default value can I sample the ad value using ads1259?

    2, calibration command is needed on adc convertion?

    3, I had read some post on to forum , someone init the chip use stop command ,is the stop command needed when init the Chip?

    4, when I read the regs values, is the rdata command needed?

    Looking forward to your reply

    Thank-you!

  • Hi mr Hall

    I have set the spi speed at 2.273MHz, and delete my delays between bytes (within a command), with out any write opcode,

    the result is all the same,

    ADS1259_REG[0] = 0x25
    ADS1259_REG[1] = 0x8
    ADS1259_REG[2] = 0xc0
    ADS1259_REG[3] = 0x0
    ADS1259_REG[4] = 0x0
    ADS1259_REG[5] = 0x0
    ADS1259_REG[6] = 0x0
    ADS1259_REG[7] = 0x0
    ADS1259_REG[8] = 0x40

    i get the sclk clk pic: i think the mcu's spi peripheral is ok.

    my spi write code is 

    void ADS1259_WRITE(uint8_t data)
    {
        //HAL_SPI_Transmit(&hspi1, &data, 1, 100);
    	
    	uint8_t pRxData = 0;
    	
    	HAL_SPI_TransmitReceive(&hspi1, &data, &pRxData, 1, 1000);
    }

    my spi read code is 

    uint8_t ADS1259_READ_REG(void)
    {
        uint8_t pTxData = 0;
    	
    	uint8_t pRxData = 0;
    	
    	//ADS1259_WRITE(0X11);//Stop Read Data Continuous mode
    	
    	//HAL_SPI_Receive(&hspi1, &pRxData, 1, 100);
    	HAL_SPI_TransmitReceive(&hspi1, &pTxData, &pRxData, 1, 1000);
    
        
        return pRxData;
    }

    and read code is 

    ADS1259_Read_Reg_Enable();
    for(i = 0; i < 9; i++) { ADS1259_REG[i] = ADS1259_READ_REG(); } HAL_Delay(200); printf("\r\n"); for(i = 0; i < 9; i++) { printf("ADS1259_REG[%d] = 0x%x\r\n",i, ADS1259_REG[i]); }

    is there any more problem that i do not consider?

  • HI mr hall,

    I do a test like this:

    spi speed 2.273MHz, and write cpcode below

    void ADS1259_INIT(void)
    {
        ADS1259_Init_Delay(DELAY_TIME_RESET);
        ADS1259_reset();
        ADS1259_Init_Delay(DELAY_TIME_RESET);
    	ADS1259_Init_Delay(DELAY_TIME_RESET);
    	ADS1259_Init_Delay(DELAY_TIME_RESET);
    	
    	ADS1259_WRITE(CMD_SDATAC);//Stop Read Data Continuous mode
    	ADS1259_WRITE(CMD_STOP);//Stop conversion 
    	//ADS1259_Init_Short_Delay(DELAY_SHORT);
        #if 1
    	ADS1259_WRITE(0X40);//write start from 00h
    	
        ADS1259_WRITE(0X08);//write 9 reg 8+1=9
    
    	
        ADS1259_WRITE(0X05);//00000101 RBIAS + spi timeout
    
    	//ADS1259_WRITE(0X01);//00000001 spi timeout
        ADS1259_WRITE(0X18);//00011000 SINC2 + EXTREF
    
        ADS1259_WRITE(0X03);//60sps , gate Convert mode
    
    	//OFC[2:0]
        ADS1259_WRITE(0X00);
    
        ADS1259_WRITE(0X00);
    
        ADS1259_WRITE(0X00);
    
    	//FSC[2:0]
        ADS1259_WRITE(0X00);
    
        ADS1259_WRITE(0X00);
    
        ADS1259_WRITE(0X40);
    #endif
        ADS1259_Init_Delay(DELAY_TIME_RESET);
    }

    other code is do not change, the read result is :

    ADS1259_REG[0] = 0x25
    ADS1259_REG[1] = 0x18
    ADS1259_REG[2] = 0xc3
    ADS1259_REG[3] = 0x0
    ADS1259_REG[4] = 0x0
    ADS1259_REG[5] = 0x0
    ADS1259_REG[6] = 0x0
    ADS1259_REG[7] = 0x0
    ADS1259_REG[8] = 0x40

    as i analsy, the 1st is wrong, cause default value is 10XX0101b is should be 0xa5 possible ,ox25 is imposible, cause bit 7 is always return 1.

    2nd value is ok,

    3rd value is ok, cause DRDY is high, EXTCLK is 1, i use Device clock source is external clockc

    can you tell me why the config0 is error?

    thank you !

    looking forward to your reply!

  • Hello, Mr hall:


    For the data sampling of ads1259, I would like to ask some questions.


    The data read by the config0 register does not match the default value, but I don't think it will affect the adc sampling. (There may be garbage data on the spi hardware cache. Is this possible?)


    I have an idea. I set the sps of the data rate setting to 14400 and then set ads1259 to Gate Control Mode. The DRDY pin is set to an external interrupt pin. (Is this ok? I think this can reduce system latency and improve real-time performance, let cpu reduce the workload, because I am using the freertos system).


    When I do the initialization above, I will wait 10ms. As you mentioned in other posts, "Settling Time Using START" takes time, for 14400 sps, 14,400 0.424(sinc1) 0.563(sinc1) at least.then use the START command to start the conversion, and at the same time open the RDATAC command. the cpu will determine if DRDY is down, there is a falling edge trigger, indicating that the data is ready, the cpu enters the interrupt, starts reading the adc data, and saves it to the ram for subsequent processing.


    Here I have more questions:


    1. What is the meaning of sinc1 and sinc2, is there any difference? Does my software need to pay attention to this?


    2. I sent SDATAC during initialization. Do I still need to send this command when I continue to send other commands later? Or do I have to send it again before sending SDATAC? (for example, after system run for 100ms, i will change some paramaters before sending RDATAC command).


    3. After sending the RDATAC command, do I need to send an RDATA command?


    4. Is the START command before or after the RDATAC command?


    5. Is CALIBRATION proceduce necessary for any adc conversion?

     

    looking forward to your reply!

    best regards!

    thanks a lot! 

  • Hello, Mr. Hall.
    I found a phenomenon when using the register reading operation.
    When I use the for loop to read, the system crashes. and goto handfault_handler function

        for (i = 0; 0 < 9; i++)
        {
            ADS1259_REG[i] = ADS1259_READ_REG();
        }

    When I don't use the for loop, I read it normally, except for the first config0.

    ADS1259_REG[0] = ADS1259_READ_REG();
    ADS1259_REG[1] = ADS1259_READ_REG();
    ADS1259_REG[2] = ADS1259_READ_REG();
    ADS1259_REG[3] = ADS1259_READ_REG();
    ADS1259_REG[4] = ADS1259_READ_REG();
    ADS1259_REG[5] = ADS1259_READ_REG();
    ADS1259_REG[6] = ADS1259_READ_REG();
    ADS1259_REG[7] = ADS1259_READ_REG();
    ADS1259_REG[8] = ADS1259_READ_REG();

    Why is this happening?
    Thank you!

  • forget this issue, cause i do error code,sorry

  • Hi Mr Hall

    today i test the ads1259

    and i set chip like this:

    ADS1259_WRITE(0X01); //0000 0001 spi timeout=1 RBIAS=0

    ADS1259_WRITE(0X08);//00001000 SINC1=0 EXTREF=1 START conversion No delay

    ADS1259_WRITE(0X00);//0000 0000 = 10sps , Gate Control mode
    and i get the the DRDY signal: the DRDY signal is 2.5us high level, 
    and i use falling exti to sample the period of DRDY, i use toggle gpio to verify, i get the gpio wave:

    void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
    {
    BaseType_t pxHigherPriorityTaskWoken;

    if (GPIO_Pin == GPIO_PIN_4)
    {
    //xSemaphoreGiveFromISR( BinarySem_Handle, &pxHigherPriorityTaskWoken );
    HAL_GPIO_TogglePin(GPIOD, SYS_LED_Pin);
    }

    /* NOTE: This function should not be modified, when the callback is needed,
    the HAL_GPIO_EXTI_Callback could be implemented in the user file
    */
    }

    i can sure the falling edge is come out every 100ms,

    but as i know , i set in gate mode, and, set Data Read Operation in Continuous Mode after start convertion, in this test ,i just sample the falling edge of DRDY ,and do not read the adc value.

    ADS1259_INIT();
    HAL_Delay(300);
    ADS1259_Start();
    HAL_Delay(300); //add delay to wait ads1259 adc Settling Time
    ADS1259_RDATAC();

    in datasheet said:

    In Gate Convert Conversion mode, DRDY returns to high on the first falling edge of SCLK

    is that result correct??

    thank you!

  • Hi Ming,

    You've made a bunch of changes to your code and asked questions related to each modification which makes it a bit difficult to follow along. I'll try to answer some of your more generic questions, but when it comes to question about why your code is not working, I don't think I'll be able to provide much help.

    Since you're using an RTOS, I would recommend trying to implement the same functionality without the RTOS to see if the issue goes away. If so, then perhaps the RTOS scheduler is interrupting your SPI communication and causing the issue.

    Regarding your schematic, I do have a few comments and questions...

    • Tying /CS low is okay, but will require you to be a bit more careful with the SPI communication to ensure that you do not lose synchronization with the ADC.

    • What is the frequency of the external clock that is connected to the XTAL1 pin?

    • I would recommend removing L1 from the DVDD power supply as this may be creating an LC resonator and resulting in an unstable supply voltage.

    ming li50749 said:
    is the ofc and fsc regs needed on my project, if I use default value can I sample the ad value using ads1259?

    Yes, you should be using the default values for now.  These registers should only be modified when calibrating.

     

    ming li50749 said:
    calibration command is needed on adc convertion?

    No, calibration is typically an infrequent operation that corrects for offset and gain errors. During normal operation you would read the data and not be issuing calibration commands.

     

    ming li50749 said:
    I had read some post on to forum , someone init the chip use stop command ,is the stop command needed when init the Chip

    The ADS1259 should be stopped by default since the START pin is tied low. I don't think you need to send the STOP command during startup, but I would send the SDATAC command upon intialization and before reading or writing to the device registers.

     

    ming li50749 said:
    when I read the regs values, is the rdata command needed?

    No, RDATA is only used for reading data. Reading registers uses the RREG command.

     

    ming li50749 said:
    can you tell me why the config0 is error?

    I'm not sure why you are reading an unexpected value for the CONFIG0 register. I would recommend inserting a long delay (to allow the SPI interface to timeout) before beginning the RREG command to ensure that the MCU and ADC communication is in sync.
     

    ming li50749 said:
    I have an idea. I set the sps of the data rate setting to 14400 and then set ads1259 to Gate Control Mode. The DRDY pin is set to an external interrupt pin. (Is this ok? I think this can reduce system latency and improve real-time performance, let cpu reduce the workload, because I am using the freertos system).

    Yes, /DRDY is typically used with an interrupt to instruct the MCU when ADC data is available.

     

    ming li50749 said:
    When I do the initialization above, I will wait 10ms. As you mentioned in other posts, "Settling Time Using START" takes time, for 14400 sps, 14,400 0.424(sinc1) 0.563(sinc1) at least.then use the START command to start the conversion, and at the same time open the RDATAC command. the cpu will determine if DRDY is down, there is a falling edge trigger, indicating that the data is ready, the cpu enters the interrupt, starts reading the adc data, and saves it to the ram for subsequent processing.

    You should issue the START command and then wait for the conversion data. However, if you're using the /DRDY interrupt to determine when the conversion is complete, then you shouldn't need to instruct the MCU to insert a delay here. Also, I would be careful to make sure that the MCU is not interrupted from the task of reading data. You'll want the MCU to complete the SPI communication before moving on to other tasks.

      

    ming li50749 said:
    What is the meaning of sinc1 and sinc2, is there any difference? Does my software need to pay attention to this?

    These are different digital filter types. SINC2 provides more noise attenuation, but takes longer to settle. See https://e2e.ti.com/blogs_/archives/b/precisionhub/archive/2016/06/10/delta-sigma-adc-digital-filter-types-sinc-filters

     

    ming li50749 said:
    I sent SDATAC during initialization. Do I still need to send this command when I continue to send other commands later? Or do I have to send it again before sending SDATAC? (for example, after system run for 100ms, i will change some paramaters before sending RDATAC command).

    SDATAC should be sent during initialization in order to read/write registers. It doesn't need to be sent with each command. Once in this mode, you should remain in this mode unless you send the RDATAC command.

     

    ming li50749 said:
    After sending the RDATAC command, do I need to send an RDATA command?

    No, RDATA is only required when in SDATAC mode. In RDATAC mode, you simply send 0x00 bytes to read the data.

     

    ming li50749 said:
    Is the START command before or after the RDATAC command?

    I would send START before the RDATAC command. In RDATAC mode, the ADC only retrieves data OR exits RDATAC mode (via the SDATAC command).

  • Hello, Mr. Hall,
    1, I use the hardware spi to drive ads1259, it should not be affected by rtos. If it is a software simulation, it must be done with 8bit protection.
    2. The frequency of XTAL-H1 is 7.3728MHz.
    3, on the removal of L1 in the DVDD power supply, I will be instructed with the superior, because the hardware is already done.
    4, " I'm not sure why you are reading an unexpected value for the CONFIG0 register. I would recommend inserting a long delay (to allow the SPI interface to timeout) before beginning the RREG command to ensure that the MCU and ADC communication is in Sync." The long delay of this sentence refers to the delay between RREG and what command? I am testing this proposal today.

  • Hello, Mr. Hall,
    Thank you for your reply, this is a big help for me.
    After the initialization of ads1259, I waited for about 3s and then sent the RREG command, but the result is still: config0 is diff from datasheet. other reg value is ok.

  • Hello, Mr. Hall,
    Thank you for your reply, this is a big help for me.

    I have read the ADC data, fffc86, I think it should be negative, and I have not performed task calibration, so do I need to do calibration in this case?
    I read the manual page 27, my understanding is this:
    1, set to PULSE = 0
    2, open the conversion start command
    3, external input input 0 or full scale
    4, waiting for some time
    5, send OFSCAL or GANCAL command
    6. Wait for the calibration to be completed. End of calibration, DRDY will be low
    Is my understanding correct? Is it necessary to input an external voltage during the calibration process? Does each chip require an external voltage input? This will increase the workload when we mass production.

  • Hello, Mr. Hall,
    I am glad that I got the data!

    I input 2.49913V in the AINP pin of ads1259, AINN is grounded, and the data sampled by ads1258 is 2.499290V.

    But I am curious, how to calibrate ads1259? Is every chip shipped out, I have to compensate in the program? Or do I use the ads1259's OFSCAL (offset calibration) or GANCAL (full-scale calibration) command to calibrate?

    If I use the command OFSCAL or GANCAL to calibrate, can you explain how to calibrate?
    In particular, I don't quite understand this sentence: Apply the appropriate input to the ADS1259 (zero or full-scale), how to operate this step?

    thank you very much!

  • Hi Ming,

    ming li50749 said:
    I read the manual page 27, my understanding is this:
    1, set to PULSE = 0
    2, open the conversion start command
    3, external input input 0 or full scale
    4, waiting for some time
    5, send OFSCAL or GANCAL command
    6. Wait for the calibration to be completed. End of calibration, DRDY will be low
    Is my understanding correct? Is it necessary to input an external voltage during the calibration process? Does each chip require an external voltage input? This will increase the workload when we mass production.

    Your sequence looks mostly correct. Setp 4's delay would only be necessary to allow the input signal to settle. Calibration wouldn't begin until step 5, and there will be a longer delay between issuing the command and waiting for /DRDY to go low.

     

    ming li50749 said:
    If I use the command OFSCAL or GANCAL to calibrate, can you explain how to calibrate?
    In particular, I don't quite understand this sentence: Apply the appropriate input to the ADS1259 (zero or full-scale), how to operate this step?

    I wrote up a fairly detailed explanation of a calibration procedure for a related device on this E2E thread: https://e2e.ti.com/support/data-converters/f/73/t/707084. Some of the SPI commands are named differently, but the same concepts apply. Look at that explanation and let me know if that helps.