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.

ads1247 evm communication problem SPI

Other Parts Discussed in Thread: ADS1247

Hi there,

i recently bought the ADS1247 EVM evaluation board for testing the ADS1247. What I basically want to achieve is a measurement of a couple of voltages only via spi (so only the GND, 3.3V, 5.0V, MOSI, MOSI, CLK and CS are connected; START, DRDY, etc are not connected, or kept HIGH/LOW by default).\

The communication is implemented using the spidev on linux with the usage of ioctl().


Reading data once works perfectly, but reading a register keeps me in trouble. What I wanted to do is reading the value of register 0, which should be 0x01h by default, but I always get back 0x00. I put a stop data continuously before reading the register, as it can bee seen from the code.

What I have tried is already reading the rx[0] rx[1] rx[2], but they are all 0x00.

Maybe anyone of you can help me with that. Thanks!

The code snippet implemented looks as follows:

#define RESET 0x06
#define NOP 0xFF
#define RDATA 0x12
#define RDATAC 0x14
#define SDATAC 0x16
#define RREG 0x20
#define WREG 0x40
#define SELFOCAL 0x62

#define MUX0 0x00
#define VBIAS 0x00
#define MUX1 0x02
#define SYS0 0x03


int main()
{

....
....

        stop_read_data_cont(fd);
	while(1){
                reg_value = read_register(fd, MUX1);
		printf("Register %.2x value is %x \n", MUX0, reg_value);
		sleep(1);
	}

}

static int32_t read_register(int fd, uint8_t addr)
{
	uint8_t tx[] = {RREG|addr, 0x00, NOP, };
	uint8_t rx[] = {0xFF, 0XFF, 0xFF};

	int ret;

	spitransfer(fd, tx, rx);
       
return rx[0]; }
static void stop_read_data_cont(int fd) { uint8_t tx[] = {SDATAC, }; spitransfer(fd, tx, NULL); } static void spitransfer(int fd, uint8_t *tx, uint8_t *rx) { int ret; struct spi_ioc_transfer tr = { .tx_buf = (unsigned long)tx, .rx_buf = (unsigned long)rx, .len = ARRAY_SIZE(tx), .delay_usecs = 0, .speed_hz = speed, .bits_per_word = bits, }; ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); if (ret < 1) perror("SPI_IOC_MESSAGE: "); }

  • After a bit of research I found out, that the CS caused the problem, since the linux driver did not keep it LOW during a communication sequence. Tying the CS to ground solved the problem. Now everything is working as planned. Thanks anyway.