This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SPI communication problem in nrf52832

 I am trying to use SST26VF064B IC in my project (We use nrf-sdk-16 ). we use a driver code that was already tried and tested with the stm32 controller. But when trying to configure with nrf52dk board (nrf52832 IC , pca10040), and read the device ID it returns a different value.

code:

int main(void)
{
    gpio_init();
    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.ss_pin   = 0XFF;                           //NRF_SPIM_PIN_NOT_CONNECTE;
    spi_config.miso_pin = SPI_MISO_PIN;                   //PIN-30
    spi_config.mosi_pin = SPI_MOSI_PIN;                   //PIN-29
    spi_config.sck_pin  = SPI_SCK_PIN;                    //PIN-26
    APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));
    //==========================================================================
  // Initialize_SST_FLASH();
  // Test_Flash_Memory();
   // nrf_gpio_pin_set(17);
  //==============================================================================
    static uint8_t SST_CMD;
    /*reset enable */
    SST_CMD=SST26_RSTEN;
    SST26_ENABLE();                             //This function set CE pin low low
    SST26_SPI_Wright((uint8_t *)&SST_CMD,1);    /*single command*/
    SST26_DISABLE();                            //This function set CE pin High
    /*reset memory*/
    SST_CMD=SST26_RST;
    SST26_ENABLE();
    SST26_SPI_Wright((uint8_t *)&SST_CMD,1);/*single command*/
    SST26_DISABLE();
    while (1)
    {
        // Reset rx buffer and transfer done flag
        memset(m_rx_buf, 0, m_length);
        do{
        //SST26_SPI_Wright(0x99,1);
        SST26_ENABLE();
        nrf_delay_ms(1);
        nrf_drv_spi_transfer(&spi, m_tx_buf, 1, NULL, 0);
        nrf_drv_spi_transfer(&spi, NULL,0, m_rx_buf, 3);
        nrf_delay_ms(1);
        SST26_DISABLE();
        }while(m_rx_buf[0]!=0xBF);
        //SST26_DISABLE();
      // printf("UART example started\r\n");
    }
}

 the device ID is 0xBF but the read value is different.

The scope image when trying to send the command 0x9f is as shown below. 

what we recieve is :

the read values while debugging.

P.S - came across a similar thread https://devzone.nordicsemi.com/f/nordic-q-a/52370/spi-interface-problem?ReplySortBy=CreatedDate&ReplySortOrder=Descending but could not resolve the issue.

what bugs me is that the same code and hardware works with stm32 discovery board.

  • Hi,

    The scope image when trying to send the command 0x9f is as shown below. 

    If blue is MOSI and yellow is SCLK then it seems like it sending the correct command 0b10011111? Could you confirm by using a logic analyzer? If it's sending the correct command, could you compare the output from the nRF and your other board and check with a scope if the sequence is the same? 

    Is there a specific reason for why you're doing this in two transactions and not one?

    regards

    Jared 

Related