How to activate QSPI mode from default SPI mode

Discussion in 'X2 & X4 SoC' started by windchime, Oct 7, 2019.

  1. windchime

    windchime New Member

    Hi,

    I'm working on custom radar board using X4. I am using SPI now but I decided to use QSPI to commnicate with X4 module. Default mode is single bit SPI when X4 is enabled. And QSPI should be activated by writing 1 to spi_mode of spi_config(0x1D) register. And then nSS should be toggled once.

    Below is the section descrbing activation of QSPI mode in X4 datasheet.

    5.1. Selecting QSPI Mode
    The spi_mode_pif bit in the spi_config_pif PIF register selects whether QSPI or SPI mode is enabled.
    In slave mode, the same bit can be accessed through the spi_mode bit in the spi_config SPI register
    which can be written with a write-only instruction over the SPI interface. This enables external SPI
    hosts to change SPI mode on the fly. Changes to this register takes effect after nSS has been
    toggled high and then low.

    nSS is active low. So it should be set to low and then high, even though it is explained to be toggled high and then low. Anyway I tried some combinations.

    _x4_spi_register_set(device, X4_ADDR_SPI_0x1D_SPI_CONFIG, spi_mode);

    /* Changes to this register takes effect after nSS has been toggled high and the n low. */
    PIO_Clear(x4->p_x4_cs);
    samv71q21_delay_msec(1);
    PIO_Set(x4->p_x4_cs);

    This is all I should to activate QSPI on X4 side in my thouhgt.

    On my custom board MCU is ATSAMV71. And nothing will change except for WIDTH field of QSPI_IFR(0x4007C038) on MCU side.

    With those settings I tried to read some SPI registers like force_zero, force_one, chip_id_dig, chip_id_sys and debug registers. But the results were weird. It didn't work.

    I would like to get some help. Any advice or sample code would be appreciated.

    Regards,
    Kyle
     
  2. Charlie Shao

    Charlie Shao Moderator Staff Member

    Hi windchime,

    See the attached pitch on how to switch to QSPI based on XEP 3.4.7.
     

    Attached Files:

  3. windchime

    windchime New Member

    Thank you, Charlie. I could rule out the x4 side settings. I checked the source files and found out that one of the PIO setting was wrong.

    Thanks again.
    Kyle