AD5668 DAC over QSPI on STM32L4
New question from: https://community.st.com/t5/stm32-mcus-products/qspi-master-and-slave/td-p/758418
I have a AD5668 DAC which supports QSPI upto 50Mhz frequency. I am trying to test the DAC with STM32 using QSPI . But I am not able to see DAC output. So I thought to debug it with two Microcontrollers like how we do with SPI.
This is my code
// Function to send data to AD5668 DAC in the specified format
void AD5668_SendCommand(uint8_t command, uint8_t channel, uint16_t voltage) {
uint8_t commandData[4];
QSPI_CommandTypeDef sCommand = {0};
HAL_StatusTypeDef status;
// QSPI command configuration
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
sCommand.AddressMode = QSPI_ADDRESS_NONE;
sCommand.DataMode = QSPI_DATA_1_LINE;
sCommand.DummyCycles = 0;
commandData[0] = command; // Command byte (e.g., 0x03)
commandData[1] = channel; // Channel byte (e.g., 0x0F)
commandData[2] = (voltage >> & 0xFF; // MSB of voltage
commandData[3] = voltage & 0xFF; // LSB of voltage
// Transmit the command via QSPI
for(int i =0; i<4; i++)
{
status= HAL_QSPI_Transmit(&hqspi, &commandData[i], HAL_MAX_DELAY)!=HAL_OK;
HAL_Delay(10);
printf("status:%d\n",status);
}
int main(void)
{
AD5668_SendCommand(0x03, 0x1F, voltage); // Send command in the specified format
}
This is QSPI Initialization :
static void MX_QUADSPI_Init(void)
{
/* QUADSPI parameter configuration*/
hqspi.Instance = QUADSPI;
hqspi.Init.ClockPrescaler = 1;
hqspi.Init.FifoThreshold = 4;
hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE;
hqspi.Init.FlashSize = 4;
hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_2_CYCLE;
hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0;
hqspi.Init.FlashID = QSPI_FLASH_ID_1;
hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE;
if (HAL_QSPI_Init(&hqspi) != HAL_OK)
{
Error_Handler();
}
}
Provide any suggestions why it is not working
