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

external spi flash memory read

Hi, 

i am trying to interface an external spi flash memory with nrf52832 to store temp. data. 

i tried to read the manufacture/device id but i am getting wrong data.

my code is as follows:

void at_read_rems(uint8_t * manufacturer_id, uint8_t * device_id)
{
    uint8_t spi_tx_cmd[] = {0x90,0x00,0x00,0x00};
    uint8_t spi_rx_response[6];
    nrf_gpio_pin_clear(SPI_SS_PIN);
    nrf_drv_spi_transfer(&spi, spi_tx_cmd, sizeof(spi_tx_cmd), spi_rx_response, sizeof(spi_rx_response));
		/*
		nrf_drv_spi_transfer(&spi, spi_tx_cmd, sizeof(spi_tx_cmd), NULL, NULL);
		nrf_gpio_pin_set(SPI_SS_PIN);
		nrf_gpio_pin_clear(SPI_SS_PIN);
		nrf_drv_spi_transfer(&spi, NULL, NULL, spi_rx_response, sizeof(spi_rx_response));
		*/
    nrf_gpio_pin_set(SPI_SS_PIN);
    *manufacturer_id = spi_rx_response[4]; 
    *device_id = spi_rx_response[5];
}
void spi_config(void)
{
    
    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
		spi_config.mode 	   =  NRF_DRV_SPI_MODE_0;  //NRF_DRV_SPI_MODE_0 NRF_DRV_SPI_MODE_3
		spi_config.bit_order =  NRF_DRV_SPI_BIT_ORDER_MSB_FIRST;  //NRF_DRV_SPI_BIT_ORDER_MSB_FIRST
		spi_config.frequency =  NRF_DRV_SPI_FREQ_1M;
    spi_config.ss_pin    =  NRF_DRV_SPI_PIN_NOT_USED;
    spi_config.miso_pin  =  SPI_MISO_PIN;
    spi_config.mosi_pin  =  SPI_MOSI_PIN;
    spi_config.sck_pin   =  SPI_SCK_PIN;
		
    APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, NULL, NULL));

    //NRF_LOG_INFO("SPI example started."); 
    nrf_gpio_cfg_output(SPI_SS_PIN);
    nrf_gpio_pin_set(SPI_SS_PIN);
    
}

int main(void)
{
    bsp_board_init(BSP_INIT_LEDS);
		
    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();
		spi_config();
    uint8_t  man_id, dev_id;
		at_read_rems(&man_id, &dev_id);
		
		nrf_delay_ms(200);
	
}

as per the datasheet man. id/ device id should be EFh/14h respectively but i am getting FCh/1Fh

thanks

Parents Reply Children
No Data
Related