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

Spi read is not happening fine,

Hi

We have custom nrf51822 board.

in that we have nor flash which is spi compatible.

so in order to read device id i used spi_master sample source code.

i am able to write data in to Nor flash.

i check with debugging also.

it is giving ack for every byte write.

but i a not able to read data from nor.

i am trying to read device id of nor.

Here is my code

int main(void) { uint32_t *spi_base_address; NRF_GPIO->PIN_CNF[30]=0; NRF_GPIO->OUTCLR=(1<<30); bool lsb_first=0; uint16_t transfer_size1=1; uint8_t data=0x06;//SPI_FLASH_INS_WREN; uint8_t recvbuf[3]={0x00}; uint8_t *tx_data1=&data; uint16_t transfer_size=3; uint8_t SPI_FLASH_INS_RDID[5]={0x9F,0x00,0x00,0x00,0x00}; uint8_t *tx_data=&SPI_FLASH_INS_RDID[0]; uint8_t *rx_data=&recvbuf[0];

spi_base_address=spi_master_init(SPI0,SPI_MODE0,lsb_first);
//spi_master_tx_rx(spi_base_address,transfer_size1,tx_data1,rx_data);

spi_master_tx_rx(spi_base_address,transfer_size,tx_data,rx_data);
      while(true)
      {
    }

}

i configured currect gpio pin spi_master_config.h

Kindly suggest me.if anyone have simple spi code for eeprom or some other hardware kindly share with me

Regards Balaji

Parents
  • static void halAfe_ConfigSPI(void)
    {
      /* UART/SPI Peripheral configuration */
    	spi_handle = spi_master_init(SPI0, SPI_MODE0, false);
    	if (spi_handle == 0)
    		; // uh-oh
    }
    void HalAfe_HW_Init(void)
    {
      /* Initialize AFE IO lines */
      halAfe_ConfigIO();
    
      /* Initialize SPI */
      halAfe_ConfigSPI();
      HalAfe_HW_Defaults();
    }
    void HalAfe_HW_EnterReadMode()
    {
    	uint32_t txdat = 1;
    	uint8_t rxdat[] = {0, 0, 0, 1};
    	txdat = swap_uint32(txdat);
    	if (spi_handle != 0)
    		spi_master_tx_rx(spi_handle, 4, (uint8_t*)&txdat, rxdat);
    }
    

    spi_master_cfg.h

    #define SPI_PSELSCK0              8   
    #define SPI_PSELMOSI0             10   
    #define SPI_PSELMISO0             9   
    #define SPI_PSELSS0               11  
    
    

    You should buy a logic analyzer if you don't have one. Your variables and names are very confusing.

    Post your part number as well. How should I know what flash you have?

  • HI Syntroniks,

    Sorry for my bad variables.

    I am using Micron Nor Flash N25Q512.

    Kindly some hints.

    Regards Balaji

Reply Children
No Data
Related