This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Problem using the nRF52840 to interface an ADS1298 via SPI

Hi DevZone,

I am using the nRF52840 to interface an ADS1298 (ECG Chip) via SPI.

I want to test if the communication between the devices are working by:

    -  Sending a RREG (Read From Register) opcode from the nRF52840 to the ADS1298

    -  And then read its ID Register.

The RREG command is two bytes long, and for multi-byte commands the following needs to be done:

    1.  Send the first byte and then wait for 4 * tCLK  before sending the next byte.

    2. The CS (or SS) pin needs to be held low during the entire session for both transfer and receive.

I am trying to test this with the example provided in the nRF5 SDK 15.3 by using this function:

    -  nrf_drv_spi_transfer(&spi, m_tx_buf, m_length, m_rx_buf, m_length);

My problem is that:

    -  I cannot insert a delay between the bytes when using the nrf_drv_spi_tranfer() for multiple byte transfers

    -  If i use separate calls of the nrf_drv_spi_transfer() for each byte, then the CS pin is not held low.

Is there any way I can use this driver to send multiple bytes with a fixed delay between them, without the CS pin going high during the session?

Thank you for reading

Br. Casper

Parents
  • Thank you very much for the insight!

    I can now see on my oscilloscope that I can send two bytes with a delay in between, and also send SCLK signal afterwards to receive the answer.

    I have not yet been successful in getting an answer from the ADS1298, but at least now I know that I am adhering to its datasheet requirements.

    I have set the Jumpers on the ADS1298 EVM (Evaluation board) to use the internal 2.048MHz clock and I have set the SPI frequency

    to 500kHz. 

    The SCLK signal is provided in bursts by the nRF52840 microcontroller as specified in the datasheet for the ADS1298, and aligns perfectly with the MOSI signal from the nRF52840 microcontroller. 

    Since I am not getting an answer, does anyone know what I might have overlooked?

    I am still trying to send the RREG opcode and the read the ID Register value just like the picture in the original post. 

Reply
  • Thank you very much for the insight!

    I can now see on my oscilloscope that I can send two bytes with a delay in between, and also send SCLK signal afterwards to receive the answer.

    I have not yet been successful in getting an answer from the ADS1298, but at least now I know that I am adhering to its datasheet requirements.

    I have set the Jumpers on the ADS1298 EVM (Evaluation board) to use the internal 2.048MHz clock and I have set the SPI frequency

    to 500kHz. 

    The SCLK signal is provided in bursts by the nRF52840 microcontroller as specified in the datasheet for the ADS1298, and aligns perfectly with the MOSI signal from the nRF52840 microcontroller. 

    Since I am not getting an answer, does anyone know what I might have overlooked?

    I am still trying to send the RREG opcode and the read the ID Register value just like the picture in the original post. 

Children
  • You may be overlooking the following; I think all family members start up in the read-continuous mode:

    "If the device is in RDATAC mode, an SDATAC command must be issued before any other commands can be sent to the device."

        AdsReset();                      // Reset ADS - not necessary if using power-on reset
        AdsSendCmd(ADS_CMND_SDATAC);     // Stop continuous mode
        // Turn on internal reference and allow time to settle
        AdsWriteReg(ADS1x9x_REG_CONFIG2, 0xA0);
    now read id ..

    Otherwise the command looks correct:

    /****************************************************************/
    /* ADS1x9x COMMAND DESCRIPTION and definitions */
    /****************************************************************/
    typedef enum {
      // System Commands
      ADS_CMND_WAKEUP    = 0x02,   // Wake-up from standby mode
      ADS_CMND_STANDBY   = 0x04,   // Enter standby mode
      ADS_CMND_RESET_CMD = 0x06,   // Reset the device registers
      ADS_CMND_START     = 0x08,   // Start/restart (synchronize) conversions
      ADS_CMND_STOP      = 0x0A,   // Stop conversion
      ADS_CMND_OFFSETCAL = 0x1A,   // Channel offset calibration - needs to be sent every time there is a change to the PGA gain
      // Data Read Commands
      ADS_CMND_RDATAC    = 0x10,   // Enable Read Data Continuous mode.
                                   // - This mode is the default mode at power-up.
      ADS_CMND_SDATAC    = 0x11,   // Stop Read Data Continuously mode
      ADS_CMND_RDATA     = 0x12,   // Read data by command; supports multiple read back.
      // Register Read/Write Commands
      ADS_CMND_RREG      = 0x20,   // Read n nnnn registers starting at address r rrrr
                                   //  - first byte 001r rrrr (2xh)(2) - second byte 000n nnnn(2)
      ADS_CMND_WREG      = 0x40    // Write n nnnn registers starting at address r rrrr
                                   //  - first byte 010r rrrr (2xh)(2) - second byte 000n nnnn(2)
    } ADS1x9xCommand_t;
    

    I should add that if you are going off-board to the ADS development board it might be necessary to boost the drive to SCK, CS and MOSI pins from S0S1 to H0H1 after the SPI has been initialised; not usually necessary at lower SCK speeds however..

Related