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: Does not work with using a multiplexer

Part Number: ADS1259

Hi there,

I'm already trying running this ADS1259 with a multiplexer. So far I could not get it running by using different multiplexer. As far as I just use one multiplexer and the same data on the others it works alright. After using different locations for the multiplexer it does not. Can you help me find the problem please?

In the following you can see the code I used:

void INIT_ADW_24bit_SPI(SPI_HandleTypeDef *hspi1){

uint8_t spi_rx[11] = { 0x0 };
uint8_t spi_tx[11] = { 0x0 };

spi_tx[0] = 0x06; // Reset

LL_GPIO_ResetOutputPin(CS_AD2_GPIO_Port, CS_AD2_Pin);
HAL_SPI_TransmitReceive(hspi1, spi_tx, spi_rx, 1, 1);
LL_GPIO_SetOutputPin(CS_AD2_GPIO_Port, CS_AD2_Pin);

HAL_Delay(1);


spi_tx[0] = 0x11; // Stop Read Data Continuous mode

LL_GPIO_ResetOutputPin(CS_AD2_GPIO_Port, CS_AD2_Pin);
HAL_SPI_TransmitReceive(hspi1, spi_tx, spi_rx, 1, 1);
LL_GPIO_SetOutputPin(CS_AD2_GPIO_Port, CS_AD2_Pin);

HAL_Delay(1);

//---------------------------------
// Configure ADS register Setup:---
//---------------------------------

// spi_tx[2] config0: 0101 --> SPI timeout enabled, internal reference bias enabled
// spi_tx[3] config1: 0011 --> sinc^1 filter, delay 256 tclk
// spi_tx[4] config2: 10110 --> 3600SPS, Pulse control mode

spi_tx[0] = 0x40; spi_tx[1] = 0x08; spi_tx[2] = 0x05; spi_tx[3] = 0x03; spi_tx[4] = 0x16; spi_tx[5] = 0x00; spi_tx[6] = 0x00; spi_tx[7] = 0x00; spi_tx[8] = 0x00; spi_tx[9] = 0x00; spi_tx[10] = 0x40;

LL_GPIO_ResetOutputPin(CS_AD2_GPIO_Port, CS_AD2_Pin);
HAL_SPI_TransmitReceive(hspi1, spi_tx, spi_rx, 11, 1);
LL_GPIO_SetOutputPin(CS_AD2_GPIO_Port, CS_AD2_Pin);


HAL_Delay(1);

spi_tx[0] = 0x20; spi_tx[1] = 0x08; // Read all Config Register

LL_GPIO_ResetOutputPin(CS_AD2_GPIO_Port, CS_AD2_Pin);
HAL_SPI_TransmitReceive(hspi1, spi_tx, spi_rx, 11, 1);
LL_GPIO_SetOutputPin(CS_AD2_GPIO_Port, CS_AD2_Pin);

HAL_Delay(1);

//spi_tx[0] = 0x10; // Read Data continuous mode
spi_tx[0] = 0x12; // Read Data config by opcode

LL_GPIO_ResetOutputPin(CS_AD2_GPIO_Port, CS_AD2_Pin);
HAL_SPI_TransmitReceive(hspi1, spi_tx, spi_rx, 1, 1);
LL_GPIO_SetOutputPin(CS_AD2_GPIO_Port, CS_AD2_Pin);

HAL_Delay(1);
}

void READ_AD_24bit(SPI_HandleTypeDef *hspi1, int32_t *temp, int32_t *offset, int32_t *offset_w){

static int COUNTER = 0;
static int CHANNAL = 0;

DEBUG_AD24raw = READ_ADW_24bit_SPI(hspi1);

temp[CHANNEL] = ...

CHANNEL++;

if (CHANNEL >= RTD_ANZAHL)
{
KANAL = 0;

// Filter
COUNTER++;
if (COUNTER > 49) COUNTER = 0;
}
SET_CH_MUX1(COUNTER);
}

uint32_t READ_ADW_24bit_SPI(SPI_HandleTypeDef *hspi1){

uint32_t temp = 0;
uint8_t spi_rx[4] = { 0 };
uint8_t spi_tx[4] = { 0x12, 0x00, 0x00, 0x00 };

LL_GPIO_ResetOutputPin(CS_AD2_GPIO_Port, CS_AD2_Pin);

HAL_SPI_TransmitReceive(hspi1, spi_tx, spi_rx, 4, 1); // Read data active and then read

LL_GPIO_SetOutputPin(CS_AD2_GPIO_Port, CS_AD2_Pin);

//------------------------------------
//Data changing

temp=...........

//------------------------------------

return temp;
}

Thanks in advance and hopefully we can find some failure in the code!

  • Hi Ferdinand Wimmer,

    It seems like your ADC is working correctly, and that you are actually having trouble operating your external multiplexer.

    A few things we noticed in the code:

    1. The declaration "static int CHANNAL" is made at the beginning of the READ_AD_24bit function, but it is referenced as "CHANNEL" after that point. You should use consistent spelling to ensure your code works correctly
    2. The READ_AD_24bit function also includes a variable "KANAL", which is never declared and never used anywhere else (at least as far as the code shows)
    3. The "static int " declarations in the READ_AD_24bit function will always set COUNTER to either 0 or 1, depending on the state of "RTD_ANZAHL", since these declarations are reinitialized each time the function is called

    I would suggest looking at a logic analyzer while you run your code so you can actually see what is being transmitted to and from the system. This will help you identify if the code is doing what you think it should.

    -Bryan

  • Hi Bryan,

    thanks for the answer! I'll look into it in the next days and reply if it helped. The CHANNEL or KANAL is the same, I just wanted all translated in english for this post. Seems like I forgot a translation of a KANAL (in the original program everything was written in the German "KANAL"). 

    Next I'll try to use a logic analyzer as you mentioned and see what exactly it shows.

    Best regards,

    Stefan

  • Hi Ferdinand Wimmer,

    Thanks for providing additional information. Please let us know what you discover as you perform additional tests

    Also, I would recommend in the future to just send your code as-is. It is challenging to provide support if we are not seeing the actual code being used, but instead an interpretation of that code. You can understand that there are errors in the code that you provided, but these might just be a result of the translation, not actual behavioral issues. We have translation tools if we cannot understand a specific language, or we can just ask you for help if necessary.

    -Bryan