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.

ADS1262: Giving Garbage value with other SPI slaves where as working perfect independently

Part Number: ADS1262

I am interfacing ADS1262 with Arduino mega2560 along with TFT and sd card.

When I interface ads1262 with above given slave at that time, sometimes it activate and given output and sometimes it does not activate and giving garbage value or zero value.

Although it is giving perfect value when running independently.

I have attached photo of interfacing design. I have also attached code for reference.

I have configured POWER and REFMUX register.

Default value of POWER register is 0x11 which is change to 0x10 (INTREF disabled).

Default value of REFMUX register is 0x00 which is change to 0x12 (AIN2 & AIN3 used as external reference).

ADC is working in continuous mode.

What may be the issue?Circuit.pdfADS1262 Issue.rtf

  • Hi Nirav,

    It looks like you have three devices on the same SPI bus. In that case you need to make sure that you're not trying to communicate with more than one device at the same time otherwise you'll have contentions on the MISO signal.

    In your code it looks like you might be talking to more than one device at time. You appear to be polling /DRDY, updating the LCD screen, and reading data in the "ADC_Error:" loop in your code. You might try inspecting TFT_CS, SD_CS, and ADC_CS on an oscilloscope to make sure that only one CS pin is active at a time here.

    Perhaps it would make sense to to write a function that controls which SPI device is activate (and ensures that all other devices on the SPI bus are inactive), that way you don't mix up the SPI communication. 

    Another good practice would be to use the /DRDY pin as an interrupt (instead of polling it in a loop). By using an interrupt you could potentially have your Arduino running another task while it's waiting for /DRDY to go low. Then once your /DRDY interrupt is triggered you could handle the interrupt, read the ADC data, and then go back other performing other tasks.

    I hope that helps!

    Best Regards,
    Chris

  • Dear Chris,

    Thanks for your suggestion.
    I have try to communicate at a time only one slave, by making its CS pin low where as all other CS pin are high.
    Can you please describe that how the function looks like which control the SPI device is active or inactive?
    How can I make the DRDY pin as an interrupt?
  • Hi Nirav,

    Sorry for the delayed response.

    I was thinking of a function call something like the following: AssertCS( "Name of device for which to set /CS low, OR 'None' to set all /CS pins high" );
    Then within the function you could first ensure that all CS pins are set high, before proceeding to set one of the /CS pins low.

    I'm not exactly sure how to implement interrupts on an Arduino, but for an MSP430 it will look like the following:  

    By using an interrupt you don't need to rely on your code checking that state of the /DRDY pin precisely after it goes low, instead you can perform other tasks while waiting for the interrupt. In the actual interrupt routine, you can decide whether you want to read the data as part of the routine, or simply set a flag that tells your main loop that it needs to go read the data. The later case is better if you have other interrupts in your code that can "interrupt" your current interrupt.

    Best Regards,
    Chris

  • Hi Nirav,

    Have you tried looking at your SPI bus with a logic analyzer (or oscilloscope) to verify that only one device is trying to communicate on the SPI bus at a time?

    Best Regards,
    Chris