How to make it work for using SPI register mode to switch different spiConfig.wordLen with CyU3PSpiSetConfig()?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
cumac_1314066
Level 1
Level 1

How to make it work for using SPI register mode to switch different spiConfig.wordLen with CyU3PSpiSetConfig()?

The example code as following is not work:

example code:

CyU3PSpiSetSsnLine (CyFalse);

CyU3PSpiDeInit();

CyU3PSpiInit();

spiConfig.wordLen = 10;

CyU3PSpiSetConfig (&spiConfig, NULL);

CyU3PSpiTransmitWords (buffer, byteCount);

CyU3PSpiDeInit();

CyU3PSpiInit();

spiConfig.wordLen = 8;

CyU3PSpiSetConfig (&spiConfig, NULL);

CyU3PSpiTransmitWords (buffer, byteCount);

CyU3PSpiSetSsnLine (CyFalse);

Q: How to get know the ready of CyU3PSpiInit() ?

Q: How to get know the CyU3PSpiTransmitWords () finish?

Q: Could you provide the example code for CyU3PSpiSetConfig() be called repeatedly to change the settings?

Best regards,

cute

0 Likes
1 Solution

Hi,

Yes it is possible to change SPI configurations dynamically. PFA firmware which is used to change the SPI config wordlength using control center. You have to send the vendor command and use wIndex field to set the desired wordlength. Changes will be highlighted in the debug prints.

Thanks & Regards
Abhinav

View solution in original post

0 Likes
3 Replies
Keerthy_V
Moderator
Moderator
Moderator
First like given 250 sign-ins 50 solutions authored

HI Cute,

Can you please let us know why do you want to change the word length dynamically?

What is the polarity of SSN line? Is it active low? If yes, please move the API CyU3PSpiSetSsnLine (CyFalse); just before CyU3PSpiTransmitWords (buffer, byteCount).

You can read the status register of the SPI slave device to check if the data transfer is completed. Please refer the following code snippet from the cyfxusbspiregmode example project:

* Wait for the status response from the SPI flash. */

CyU3PReturnStatus_t

CyFxSpiWaitForStatus (

        void)

{

    uint8_t buf[2], rd_buf[2];

    CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

    /* Wait for status response from SPI flash device. */

    do

    {

        buf[0] = 0x06;  /* Write enable command. */

        CyU3PSpiSetSsnLine (CyFalse);

        status = CyU3PSpiTransmitWords (buf, 1);

        CyU3PSpiSetSsnLine (CyTrue);

        if (status != CY_U3P_SUCCESS)

        {

            CyU3PDebugPrint (2, "SPI WR_ENABLE command failed\n\r");

            return status;

        }

        buf[0] = 0x05;  /* Read status command */

        CyU3PSpiSetSsnLine (CyFalse);

        status = CyU3PSpiTransmitWords (buf, 1);

        if (status != CY_U3P_SUCCESS)

        {

            CyU3PDebugPrint (2, "SPI READ_STATUS command failed\n\r");

            CyU3PSpiSetSsnLine (CyTrue);

            return status;

        }

        status = CyU3PSpiReceiveWords (rd_buf, 2);

        CyU3PSpiSetSsnLine (CyTrue);

        if(status != CY_U3P_SUCCESS)

        {

            CyU3PDebugPrint (2, "SPI status read failed\n\r");

            return status;

        }

    } while ((rd_buf[0] & 1)|| (!(rd_buf[0] & 0x2)));

    return CY_U3P_SUCCESS;

}

0 Likes

Hi,

using FX3 SPI register mode to send out 10A8D(10 bits address and 8 bits data) at one SSL active low interval.

Need to change the word length dynamically for the different bits data.

Could you provide us the example code for send out 10A8D(10 bits address and 8 bits data) at one SSL active low interval using FX3 SPI register mode?

0 Likes

Hi,

Yes it is possible to change SPI configurations dynamically. PFA firmware which is used to change the SPI config wordlength using control center. You have to send the vendor command and use wIndex field to set the desired wordlength. Changes will be highlighted in the debug prints.

Thanks & Regards
Abhinav

0 Likes