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!