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

SPI RX problem (Only receive 0x00)

Hello,

I try to make my NRF52832 communicates with a memory (MX25R1635FZUIL0) in SPI.

When I try to read the memory ID, the RX buffer is fill with 0x00. But when I observe the MISO pin on the oscilloscope, I see the memory send some data.

I configure the SPI with the default configuration then change :

  • MSB first
  • mode : 3
  • frequency : 8M
  • miso : 9
  • mosi : 15
  • sck : 14
  • cs : 7

I read that the pin 9 can also be used as NFC antenna (as you can see here). Is that why I can't receive anything ?

Thanks in advance for your answer.

Best regards,

Malo

  • I don't think reading in PIN 9 makes you not to receive anything. You can try other pins to check it, btw. Can you post your SPI code to read the memory ID?

  • I can't change the SPI pins on my board (it is very integrated). But I have tested exactly the same code except the SPI and memory Reset and WP pins with the DWM1001 development board connected the same memory model in a different package and it worked well with the following pins :

    • miso : 7
    • mosi : 6
    • slk : 4
    • cs : 3
    • RST : 8
    • WP : 15

    My code is inserted below :

    void Initial_Spi()
    {
        nrf_gpio_pin_write(MX25_WP, 1);
        nrf_gpio_pin_write(MX25_CS, 1);
    
        nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config.ss_pin   = NRF_DRV_SPI_PIN_NOT_USED;
        spi_config.miso_pin = MX25_SO;
        spi_config.mosi_pin = MX25_SI;
        spi_config.sck_pin  = MX25_SCLK;
        spi_config.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST;
    
        spi_config.mode = NRF_DRV_SPI_MODE_3;
        spi_config.frequency = NRF_SPI_FREQ_8M;
        
        APP_ERROR_CHECK(nrf_drv_spi_init(&MXspi, &spi_config, spi_event_handler, NULL));
    
        // Wait flash warm-up
        Wait_Flash_WarmUp();
    
        // Release the chip from powerdown mode
        CS_Low();
        SendByte( FLASH_CMD_RES, SIO );
        CS_High();
    
        nrf_delay_us(30000);
    }
    
    void CS_Low()
    {
        nrf_gpio_pin_write(MX25_CS, 0);
    }
    
    void CS_High()
    {
        nrf_gpio_pin_write(MX25_CS, 1);
        nrf_gpio_pin_write(MX25_WP, 1);
    }
    
    void SendByte( uint8_t byte_value)
    {
        spi_xfer_done = false;
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&MXspi, &byte_value, 1, NULL, 0));
        while(spi_xfer_done == false)
        {
          __WFE();
        }
    }
    
    uint8_t GetByte( void )
    {
        uint8_t data_buf = 0;
    
        spi_xfer_done = false;
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&MXspi, NULL, 0, &data_buf, 1));
        while(spi_xfer_done == false)
        {
          __WFE();
        }
        return data_buf;
    }
    
    ReturnMsg CMD_RDID( uint32_t *Identification )
    {
        uint32_t temp;
        uint8_t  gDataBuffer[3];
    
        // Chip select go low to start a flash command
        CS_Low();
    
        // Send command
        SendByte( FLASH_CMD_RDID);
    
        //nrf_delay_us(10);
        // Get manufacturer identification, device identification
        gDataBuffer[0] = GetByte();
        gDataBuffer[1] = GetByte();
        gDataBuffer[2] = GetByte();
        
        // Chip select go high to end a command
        CS_High();
    
        // Store identification
        temp =  gDataBuffer[0];
        temp =  (temp << 8) | gDataBuffer[1];
        *Identification =  (temp << 8) | gDataBuffer[2];
    
        return FlashOperationSuccess;
    }

    Thanks,

    Malo

  • I found the solution of my problem !

    When you want to use a NFC pin as GPIO you have to add in the project prepocessor definitions "CONFIG_NFCT_PINS_AS_GPIOS" as explain here. This also applies to SPI pins and other protocols I imagine.

    Thanks,

    Malo

Related