Here goes his request:
Hello, I am using ADS8686EVM kit to for digitizing a signal from eight
channels using Software mode and one SPI to get result.
The difficulty is that I do not know correct
format to transmit (and when) the channel number to switch the
multiplexer before converting.
I always read the correct result from channel A0, B0, but other channels
transmit the same value, independent of the real signal.
From Data Sheet it is no clear to me what "corresponding register"
should I use to change channel number before conversion and what format
needed (with or without register addres CH_SEL, WR bit?)
It would be great if You can provide code examples or data exchange
diagramm for this mode.
My function to change channel and read result using CUBEIDE+ STM32F407:
void start_conv(char ch_a, char ch_b)
{
int tempshort;
static status;
char txdata[8];
CS_ENABLE;
CONVST_ENABLE;
while(BUSY_PIN);
CONVST_DISABLE;
CS_ENABLE;
tempshort = 0;
tempshort |= 0b1000000000000000; // RW
tempshort |= CHANNEL_SEL << 9;
tempshort |= ((ch_b << 4) | (ch_a)) & 0x00FF;
txdata[0] = (tempshort >> 8);
txdata[1] = (tempshort & 0xFF);
// txdata[2] = (tempshort >> 8);
// txdata[3] = (tempshort & 0xFF);
HAL_SPI_TransmitReceive(&hspi2, &txdata, &spi_rx_data, 4, 100); //
what I need to transmite in 3,4 bytes? I need to tx it, because I need
to read 2-th word of B-ch result
CS_DISABLE;
adc_a[ch_a] = ((short)spi_rx_data[0] << 8) + ((short)spi_rx_data[1]);
adc_b[ch_b] = ((short)spi_rx_data[2] << 8) + ((short)spi_rx_data[3]);
CS_DISABLE;
}
void send_config(char regadr, char indata)
{
static short data2write;
static char data_out[2];
// надо собрать в 16 бит адрес регистра, данные и бит
// 15 R/W
// 14...9 regadr
// 7 ...0 data
data2write = 0;
data2write |= 0b1000000000000000; // RW
data2write |= regadr << 9;
data2write |= indata & 0x00FF;
data_out[0] = (data2write >> 8);
data_out[1] = (data2write & 0xFF);
while(HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY); // пока не
закончит передачу
CS_ENABLE;
HAL_SPI_Transmit_DMA(&hspi2, &data_out, 2); // по spi сделать
запрос данных
HAL_Delay(1);
CS_DISABLE;
HAL_Delay(1);
}