Skip to main content
Visitor II
January 6, 2025
Solved

AD5668 DAC over QSPI on STM32L4

  • January 6, 2025
  • 2 replies
  • 824 views

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

 

    This topic has been closed for replies.
    Best answer by KDJEM.1

    Hello @Gowthami412 and welcome to the community;

     

    For communication, the QUADSPI can only be used as master only, it cannot be a master and slave like SPI.

    It is necessary to check the compatibility of the command between the QUADSPI interface and DAC device: such as command order (instruction phase, address phase, alternate-byte phase, dummy-cycle phase, data phase) and the bytes number for each command. 

    For more information, look to Overall FAQs for QUADSPI/OCTOSPI/HSPI/XSPI and precisely "1.1. How to check whether a device is supported" and "1.5. Can I use the interfaces as classic-SPI?" FAQs 

    May be these post can help you to use the QUADSPI interface as legacy SPI:

    Solved: Can I use OCTOSPI as a Classic SPI? - STMicroelectronics Community

    -  Solved: Which OCTOSPI pins can be used as MOSI and MISO in... - STMicroelectronics Community

    Solved: Re: Octal SPI Interface - STMicroelectronics Community

     

    I hope this help you.

    Thank you.

    Kaouthar

    2 replies

    Graduate
    January 6, 2025

    First of all, you have configured your QSPI in 1 data line mode, which in turn makes it just a normal SPI. No point of using QSPI for this.

    Quick glance through the Datasheet of the DAC shows, that the DAC does NOT support QSPI (well, okay, technically it does, but only in this one data line mode, which is effectively just normal SPI).

    QSPI means QUAD-SPI -> that means 4 data lines in parallel + Clk -> that means 4x throughput per 1 clock cycle. And it makes sense to utilize that interface fully with appropriate peripherals, which actually support QSPI itf.

     

    TL;DR: Just use normal SPI, save yourself the trouble.

    KDJEM.1Answer
    Technical Moderator
    January 6, 2025

    Hello @Gowthami412 and welcome to the community;

     

    For communication, the QUADSPI can only be used as master only, it cannot be a master and slave like SPI.

    It is necessary to check the compatibility of the command between the QUADSPI interface and DAC device: such as command order (instruction phase, address phase, alternate-byte phase, dummy-cycle phase, data phase) and the bytes number for each command. 

    For more information, look to Overall FAQs for QUADSPI/OCTOSPI/HSPI/XSPI and precisely "1.1. How to check whether a device is supported" and "1.5. Can I use the interfaces as classic-SPI?" FAQs 

    May be these post can help you to use the QUADSPI interface as legacy SPI:

    Solved: Can I use OCTOSPI as a Classic SPI? - STMicroelectronics Community

    -  Solved: Which OCTOSPI pins can be used as MOSI and MISO in... - STMicroelectronics Community

    Solved: Re: Octal SPI Interface - STMicroelectronics Community

     

    I hope this help you.

    Thank you.

    Kaouthar

    Visitor II
    January 6, 2025

    Thank you for your quick response. I will find an QSPI flash memory and will test QSPI using STM32.

     

    Regards 

    Gowthami412