Other Parts Discussed in Thread: ADS131M04
Tool/software:
Hello everyone, how are you?
I have a few questions regarding the configuration and data reading of the ADS131M08. I've been working with this ADC for a short time and have encountered some difficulties. I believe I’ve correctly configured the ADC for continuous reading, but I can't see any variation in the values (in bits on the oscilloscope), even when altering the analog input value.
I’m using an ST microcontroller and so far I've been able to write to registers and read them back to verify the writing. I managed to reset it via command, but not via pin. Now I want to perform continuous data reading. I’m changing the analog input value and monitoring the SPI communication with an oscilloscope, but the frame corresponding to the analog reading value does not change.
I’ve configured the program to read only on AI1, and the SPI word sent by the ADC is made up of 10 frames, where frames 3 to 10 are the analog inputs, and I don’t know what the first two frames represent. Could you help me?
void reset_ads (void) { HAL_SPI_Transmit(&hspi3, reset, 3, 100); int i = 0; int num_repeticoes = 9; while (i < num_repeticoes) { HAL_SPI_Receive(&hspi3, data_readed, 3, 100); data_readed[0] = 0b00000000; data_readed[1] = 0b00000000; data_readed[2] = 0b00000000; i++; } } void standby (void) { uint8_t standby [3]; standby [0] = 0b00000000; standby [1] = 0b00100010; standby [2] = 0b00000000; HAL_SPI_Transmit (&hspi3, standby, 3, 100); } int main(void) { HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_USART2_UART_Init(); MX_SPI3_Init(); MX_UART4_Init(); MX_UART5_Init(); pre_data [0] = 0b10100001; pre_data [1] = 0b10000000; pre_data [2] = 0b00000000; data_readed [0] = 0b00000000; data_readed [1] = 0b00000000; data_readed [2] = 0b00000000; reset [0] = 0b00000000; reset [1] = 0b00010001; reset [2] = 0b00000000; wrdata[0] = 0b01100001; wrdata[1] = 0b10000000; wrdata[2] = 0b00000000; clkreg [0] = 0b00000010; clkreg [1] = 0b01001110; clkreg [2] = 0b00000000; //-------------------- reset_ads(); HAL_Delay(1); //STAND-BY HAL_GPIO_WritePin (CS_ADS131M08_GPIO_Port, CS_ADS131M08_Pin, GPIO_PIN_RESET); standby(); HAL_Delay(1); HAL_GPIO_WritePin (CS_ADS131M08_GPIO_Port, CS_ADS131M08_Pin, GPIO_PIN_SET); //CONFIGURAÇÃO DOS CANAIS DE LEITURA DO ADC EM 03H HAL_GPIO_WritePin (CS_ADS131M08_GPIO_Port, CS_ADS131M08_Pin, GPIO_PIN_RESET); HAL_SPI_Transmit (&hspi3, wrdata, 3, 100); //WRITE IN 03H asm("nop"); HAL_SPI_Transmit (&hspi3, clkreg, 3, 100); //DATA 03H HAL_GPIO_WritePin (CS_ADS131M08_GPIO_Port, CS_ADS131M08_Pin, GPIO_PIN_SET); //WAKEUP ADC HAL_GPIO_WritePin (CS_ADS131M08_GPIO_Port, CS_ADS131M08_Pin, GPIO_PIN_RESET); HAL_SPI_Transmit (&hspi3, wakeup, 3, 100); //COMANDO WAKEUP HAL_GPIO_WritePin (CS_ADS131M08_GPIO_Port, CS_ADS131M08_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin (CS_ADS131M08_GPIO_Port, CS_ADS131M08_Pin, GPIO_PIN_RESET); data_readed [0] = 0b00000000; data_readed [1] = 0b00000000; data_readed [2] = 0b00000000; while (1) { int i = 0; int num_repeticoes = 10; while (i < num_repeticoes) { HAL_SPI_Receive(&hspi3, data_readed, 3, 100); data_readed[0] = 0b00000000; data_readed[1] = 0b00000000; data_readed[2] = 0b00000000; i++; } } }