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

Reading from slave chip (ADS1293) through SPI

Hi everyone!

I'm trying to read a register from the ADS1293 chip by using SPI but have been stuck for a good two days. The very basic code I have is right below:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define SPI_INSTANCE 0
static uint8_t tx;
static uint8_t rx;
static const nrf_drv_spi_t m_spi_master_0 = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);
void ADS_init( void )
{
nrf_drv_spi_config_t const spi_config =
{
.sck_pin = 27,
.mosi_pin = 6,
.miso_pin = 42,
.ss_pin = 44,
.irq_priority = APP_IRQ_PRIORITY_LOW,
.orc = 0xFF,
.frequency = NRF_DRV_SPI_FREQ_4M,
.mode = NRF_DRV_SPI_MODE_0,
.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST,
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

There are two things I'm not 100% sure about:

1) If the pins I'm using are correct. Is there any way to make sure that the pins I'm using are correct that is simpler than managing to read the register on the ADS? Here's how they are connected:

 NRF      ADS
P0.19 -> SDO
P0.20 -> SDI
P0.04 -> SCLK
P0.03 -> CSB

2) If the way I'm using nrf_drv_spi_transfer is correct for the ADS. If I understand correctly what's on page 37 in their documentation I should send in 8 bits and will receive 8 bits and I do this by sending in the uint8_t tx (address but set the first bit to 1) and uint8_t rx. 

When I do this I get the NRF_SUCCESS code but the data received is 0x00 and is supposed to be 0x02 for the register I'm trying. I'm really new to this so I have really no idea what I should be doing right now.

  • Is there any way to make sure that the pins I'm using are correct

    Get an oscilloscope and look at what's happening on the wires.

  • Hi

    It seems like you've mixed up the SPI pin configuration, as you should refer to the pin configuration chapter when configuring pins, and not the pin assignments. The sck_pin, mosi_pin, miso_pin, and ss_pin configured like this for the setup you're describing.

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Best regards,

    Simon

  • Thank you! Now the execution gets stuck at nrf_drv_spi_transfer which never returns anything do you know any potential reasons for that?

  • Again, have you used an oscilloscope to see what's happening on the wires?

    Have you used the debugger to find exactly where it's getting stuck within the software?

  • Edit: Looks like the ADS1293 is quite different (upgraded) from the ADS1291/2/8 so some of these comments may not apply.

    There are a number of other issues with your settings. Start with a slower clock and SPI Mode 1:

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Note you need to stop continuous read mode before accessing registers by sending command ADS_CMND_SDATAC:

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Have a look at the answers we provided in this link: interface-an-ads1298-via-spi

1 2 3 4