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

SPI issue with softdevice enabled on nRF52840

Our application uses and external nand flash to store the data samples. The collected data is then be transferred using USB. So we chose usbd_ble_uart example and wrote code over it. We are seeing this weird problem of not detecting NAND flash when nRF52840 is erased and programmed. No matter how many times we restart the application, it doesn't work. We've modified spi example in peripherals folder to read ID of the flash. After running this example, the flash starts detecting in our application written over usbd_ble_uart.
Again if we erase the program and program softdevice using nrf gostudio, and then download the application code using segger embedded studio, it is behaves the same. What might be the issue?

Edit: I am using BMD340 (nrf52840 based module). Is this because of any hardware issue?

Best regards,

Vishnu Pradeep

Parents Reply Children
  • int main(void)
    {
       // bsp_board_init(BSP_INIT_LEDS);
    
        APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    
    
    
        nrf_gpio_cfg_output(10);
        nrf_gpio_cfg_output(25);
    
       nrf_gpio_pin_set(10);
    
        nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config.ss_pin   =NULL ;
        spi_config.miso_pin =7;
        spi_config.mosi_pin =9;
        spi_config.sck_pin=8;
        APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));
    
    
        NRF_LOG_INFO("SPI example started.");
    
      // Reset rx buffer and transfer done flag
            memset(rx_buf, 0, 200);
            memset(tx_buf, 0, 200);
            tx_buf[0]=0x9F;
            tx_buf[1]=0x00;
            spi_xfer_done = false;
            
             nrf_gpio_pin_clear(10);
    
    
            APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, tx_buf, 2, rx_buf, 4));
            //APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, 2, m_rx_buf, m_length));
    
            while (!spi_xfer_done)
            {
                __WFE();
            } 
            nrf_gpio_pin_set(10);
        if(m_rx_buf[2]==0x98 && m_rx_buf[3] == 0xBD){
        NRF_LOG_INFO("Flash detected.");
        }
        else{
        NRF_LOG_INFO("Flash not detected.");
        }
           
            while(1);
        
    }

    This is the code I used to check data. It reads ID properly. 

Related