Hello,
We are using the nrf52840 with the SDK v17.0.2
We are trying to read specific addresses from our external NVM using the SPIM driver. Unfortunately when we examine our receive buffer, the data is not what we expect.
We format our command in the following order:
command = EXT_NVM_READ
uint8_t formatNvmCmd( uint8_t *txBuffer, uint32_t address, uint8_t command ){
*txBuffer = command;
*( ++txBuffer ) = ( address >> 16 ) & 0xFF; *( ++txBuffer ) = ( address >> 8 ) & 0xFF; *( ++txBuffer ) = address & 0xFF;
}
Our tx_buffer and rx_buffer are initialized as below:
#define SPIM_XFER_BUF_LEN ( 256 ) static uint8_t m_tx_buf[SPIM_XFER_BUF_LEN] = { 0 }; static uint8_t m_rx_buf[SPIM_XFER_BUF_LEN] = { 0 };
We utilize the SDK and its functions as below:
memcpy( m_tx_buf, formattedCmd, cmdLen );
nrfx_spim_xfer_desc_t xfer_desc_data_buf = NRFX_SPIM_XFER_TRX( m_tx_buf, cmdLen, m_rx_buf, dataLen );
memset( m_rx_buf, 0, dataLen );
retCode = nrfx_spim_xfer( &spiInstance, &xfer_desc_data_buf, 0 );
memcpy(dataBuff, &m_rx_buf[1], dataLen);
When we examine the dataBuff, it does not have the expected values, currently the NVM is completely set, so we expect for a datalen = 5, five 0xFF, but instead we get four 0x00 and one 0xFF.