Thank you for your reply. I'm currently unsure how to parse the response data when sending configuration commands. However, I can see that the register status is already configured in the second frame when I use the READ-HWORD command. I'd like to confirm that, when reading data periodically in automatic mode, the host can obtain data by sending 0x00. Here is the function, and I appreciate your help:
c复制
uint32_t Read_ADS8699(void) {uint32_t command = 0xC8000000;// Command to read the data register (address 0x00)uint16_t tx_buffer[2] = {0x0000};// Transmission buffer initialized with 0x0000uint16_t rx_buffer[2];// Reception buffer// Pull CS pin low to start communicationHAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);HAL_SPI_TransmitReceive(&hspi1, (uint8_t*)tx_buffer, (uint8_t*)rx_buffer, 2, HAL_MAX_DELAY);// Transmit the read command and receive the first 16-bit data// Combine the 18-bit datauint32_t data = ((uint32_t)(rx_buffer[0] & 0x00FF) << 16) | rx_buffer[1];// Shift the upper 8 bits left by 16 positions and combine with the lower 16 bits//data = data >> 6;// Uncomment this line if you need to right-shift the data by 6 bits (not necessary in this case)// Pull CS pin high to end communicationHAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);return data;
}
I have configured the ADS8699 to set the voltage range to ±5.12V through the following register settings:
c复制
void SDI_REG_WRITE(void) // Set range
{uint8_t command = 0xD0;uint8_t addr = 0x08;uint8_t H = 0x00;uint8_t L = 0x00;HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);HAL_SPI_Transmit(&hspi1, &command, 1, HAL_MAX_DELAY);// Send write commandHAL_SPI_Transmit(&hspi1, &addr, 1, HAL_MAX_DELAY);// Send register addressHAL_SPI_Transmit(&hspi1, &H, 1, HAL_MAX_DELAY);// Send high byteHAL_SPI_Transmit(&hspi1, &L, 1, HAL_MAX_DELAY);// Send low byteHAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);}void RANG_REG_WRITE(void) // Set range
{uint8_t command = 0xD0;uint8_t addr = 0x14;uint8_t H = 0x00;uint8_t L = 0x03;HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);HAL_SPI_Transmit(&hspi1, &command, 1,_MAX HAL_DELAY);// Send write commandHAL_SPI_Transmit(&hspi1, &addr, 1, HAL_MAX_DELAY);// Send register addressHAL_SPI_Transmit(&hspi1, &H, 1, HAL_MAX_DELAY);// Send high byteHAL_SPI_Transmit(&hspi1, &L, 1, HAL_MAX_DELAY);// Send low byteHAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);}void RST_REG_WRITE(void) // Reset register
{uint8_t command = 0xD0;uint8_t addr = 0x04;uint8_t H = 0x69;uint8_t L = 0x00;HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);HAL_SPI_Transmit(&hspi1, &command, 1, HAL_MAX_DELAY);// Send write commandHAL_SPI_Transmit(&hspi1, &addr, 1, HAL_MAX_DELAY);// Send register addressHAL_SPI_Transmit(&hspi1, &H, 1, HAL_MAX_DELAY);// Send high byteHAL_SPI_Transmit(&hspi1, &L, 1, HAL_MAX_DELAY);// Send low byteHAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);}void RST1_REG_WRITE(void) // Reset register
{uint8_t command = 0xD0;uint8_t addr = 0x04;uint8_t H = 0x00;uint8_t L = 0x00;HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);HAL_SPI_Transmit(&hspi1, &command, 1, HAL_MAX_DELAY);// Send write commandHAL_SPI_Transmit(&hspi1, &addr, 1, HAL_MAX_DELAY);// Send register addressHAL_SPI_Transmit(&hspi1, &H, 1, HAL_MAX_DELAY);// Send high byteHAL_SPI_Transmit(&hspi1, &L, 1, HAL_MAX_DELAY);// Send low byteHAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);}void DATA_REG_WRITE(void) // Data output format register
{uint8_t command = 0xD0;uint8_t addr = 0x10;uint8_t H = 0x00;uint8_t L = 0x00;HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);HAL_SPI_Transmit(&hspi1, &command, 1, HAL_MAX_DELAY);// Send write commandHAL_SPI_Transmit(&hspi1, &addr, 1, HAL_MAX_DELAY);// Send register addressHAL_SPI_Transmit(&hspi1, &H, 1, HAL_MAX_DELAY);// Send high byteHAL_SPI_Transmit(&hspi1, &L, 1, HAL_MAX_DELAY);// Send low byteHAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);}
However, when I read the converted value from the ADS8699 using the following function, the result is always around 6.2V, while the actual input voltage is -4.8V:
c复制
uint32_t Read_ADS8699(void) {uint32_t command = 0xC8000000;// Command to read data register (address 0x00)uint8_t tx_buffer[4];uint8_t rx_buffer[4];tx_buffer[0] = 0x00;tx_buffer[1] = 0x00;tx_buffer[2] = 0x00;tx_buffer[3] = 0x00;// CS low, start communicationHAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);HAL_SPI_TransmitReceive(&hspi1, (uint8_t*)tx_buffer, (uint8_t*)rx_buffer, 4, HAL_MAX_DELAY);// Transmit and receive datauint32_t data = rx_buffer[0] << 24;data |= rx_buffer[1] << 16;data |= rx_buffer[2] << 8;data |= rx_buffer[3];data = (data & 0xfffc0000) >> 14;// Extract the 18-bit data// CS high, end communicationHAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);return data;
}
I'm not sure why the reading is incorrect. Can you help me identify the issue?
Who is the customer and what is the application/end equipment? Can you please provide screen shots fro an o'scop or logic analyzer?
TRANSLATE with x
English
Arabic
Hebrew
Polish
Bulgarian
Hindi
Portuguese
Catalan
Hmong Daw
Romanian
Chinese Simplified
Hungarian
Russian
Chinese Traditional
Indonesian
Slovak
Czech
Italian
Slovenian
Danish
Japanese
Spanish
Dutch
Klingon
Swedish
English
Korean
Thai
Estonian
Latvian
Turkish
Finnish
Lithuanian
Ukrainian
French
Malay
Urdu
German
Maltese
Vietnamese
Greek
Norwegian
Welsh
Haitian Creole
Persian
TRANSLATE with
COPY THE URL BELOW
Back
EMBED THE SNIPPET BELOW IN YOUR SITE
Enable collaborative features and customize widget: Bing Webmaster Portal
Back