Tool/software:
I am using STM32 to read and write registers of DAC60504. I first tried to read Device ID but I am getting just 0x00000000 as a response. My SPI configured at 16-bit word size and MSB first bit order.
My function to read register is
uint16_t DAC60504_ReadRegister(uint8_t reg) {
uint16_t txData1, txData2;
uint16_t rxData1, rxData2;
uint16_t result = 0;
// Construct 24-bit Read Command (split into two 16-bit words)
txData1 = (DAC60504_CMD_READ | (reg & 0x0F)); // First 16-bit word (Command + Address)
txData2 = 0x0000; // Dummy data to complete 24-bit frame
// First SPI Transaction (Send Read Command)
DAC60504_CS_LOW();
HAL_SPI_Transmit(&hspi3, (uint8_t*)&txData1, 1, HAL_MAX_DELAY);
HAL_SPI_Transmit(&hspi3, (uint8_t*)&txData2, 1, HAL_MAX_DELAY);
DAC60504_CS_HIGH();
HAL_Delay(1); // Ensure timing is met
// Second SPI Transaction (Read Response)
txData1 = 0x0000; // Dummy Data
txData2 = 0x0000;
DAC60504_CS_LOW();
HAL_SPI_Receive(&hspi3, (uint8_t*)&rxData1, 1, HAL_MAX_DELAY);
HAL_SPI_Receive(&hspi3, (uint8_t*)&rxData2, 1, HAL_MAX_DELAY);
DAC60504_CS_HIGH();
// Extract the 16-bit data
result = rxData2; // The last 16 bits contain the actual data
return result;
}
please help me to resolve the issue.
Hi Omkar,
First, can you confirm with a scope or logic analyzer that you are sending 3 bytes? From your code, looks like you are only sending 2x bytes. Also, ensure your edge relationship with the clock and data line are correct.
Please try to read address 0x01, as that should be the CHIP ID and provide a non-zero value.
Thanks,
Paul