This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3200MOD: Reading Incorrect value from SPI

Part Number: CC3200MOD
Other Parts Discussed in Thread: CC3200

Hi all,

Today I am continuing to try to get a SPI Flash peripheral up and going with the CC3200. I cannot currently read in correct values from the external SPI Flash. Everything checks out when I watch the communication via a logic analyzer. The CC3200 sends the right sequence of bytes and the peripheral makes an appropriate response.I would expect the last byte read into "ulSpiBuf" be 0x19. Instead, the value read in stays at zero.

Here is the LA output:

Here is my configuration for the SPI:

    MAP_SPIConfigSetExpClk(GSPI_BASE, MAP_PRCMPeripheralClockGet(PRCM_GSPI),
    SPI_IF_BIT_RATE,
                           SPI_MODE_SLAVE, SPI_SUB_MODE_0, (SPI_HW_CTRL_CS |
                           SPI_4PIN_MODE |
                           SPI_TURBO_OFF |
                           SPI_CS_ACTIVEHIGH |
                           SPI_WL_8));

And here is my series of calls to send the command to the SPI Flash:

    //Write to pin 61, low
    GPIOPinWrite(GPIOA0_BASE, 0x40, 0);

    unsigned char c = 0x90;
    MAP_SPITransfer(GSPI_BASE, &c, &ulSpiBuf, 1, 0);

    unsigned char a = 0x00;
    MAP_SPITransfer(GSPI_BASE, &a, &ulSpiBuf, 1, 0);

    MAP_SPITransfer(GSPI_BASE, &a, &ulSpiBuf, 1, 0);

    MAP_SPITransfer(GSPI_BASE, &a, &ulSpiBuf, 1, 0);

    MAP_SPITransfer(GSPI_BASE, &a, &ulSpiBuf, 1, 0);

    MAP_SPITransfer(GSPI_BASE, &a, &ulSpiBuf, 1, 0);
    
    //Write to pin 61, high
    GPIOPinWrite(GPIOA0_BASE, 0x40, 0xFF);

Unfortunately I have not found any clear answers while searching around in the forums. Does any one have thoughts on what I might be missing, either in the configuration or implementation? Thanks for your time!

Best regards,

Eric

  • Hi Eric,

    From looking at the parameters in your SPIConfigSetExpClk() call, it seems like your SPI interface on the CC3200 is configured as a SPI slave, with active high CS. Are you sure these are the correct settings for your use case? Looking at the logic analyzer capture, it seems like the CS signal goes low when the SPI interface is clocked. Try changing the configuration of the CC3200 SPI interface to expect active-low CS by passing in the SPI_CS_ACTIVELOW parameter instead of SPI_CS_ACTIVEHIGH.

    Regards,

    Michael
  • Hello Michael,

    I realized that I copied the wrong configuration into my original description. Below is the configuration that I have been using that so far has produced the behavior above.

    Best regards,

    Eric

        // Configure SPI interface
        MAP_SPIConfigSetExpClk(GSPI_BASE, MAP_PRCMPeripheralClockGet(PRCM_GSPI),
        SPI_IF_BIT_RATE,
                               SPI_MODE_MASTER, SPI_SUB_MODE_3, (SPI_HW_CTRL_CS |
                               SPI_4PIN_MODE |
                               SPI_TURBO_OFF |
                               SPI_CS_ACTIVELOW |
                               SPI_WL_8));

  • Hi Eric,

    In your screenshot, it seems like the SPI interface should be set as SPI_SUB_MODE_0 instead of SPI_SUB_MODE_3, as your clock is active-high and you are sampling the value on the data lines at the rising edge of the clock.

    Something else to check would be the pin mux from the SPI peripheral to the device's external pins. How are you setting up the pin mux for the SPI interface? You should have something along the lines of this in your code somewhere:

        MAP_PinTypeSPI(PIN_05, PIN_MODE_7);
        MAP_PinTypeSPI(PIN_08, PIN_MODE_7);
        MAP_PinTypeSPI(PIN_07, PIN_MODE_7);
        MAP_PinTypeSPI(PIN_06, PIN_MODE_7);

    Lastly, how are you probing the SPI signals? Are you probing them at the muxed SPI pins of the module? There could be some hardware issue that is preventing the module from seeing the MISO signal.

    Regards,

    Michael

  • Hi Michael,
    It looks like I might have been having a pinmux issue. I will post an update when I know for sure in the morning.

    Thanks for your help!
    -Eric