I am working on reading ADXL362 through SPI on PCA10040.I used demo spi in nRF5_SDK_13.1.0. here is my main code:
bsp_board_leds_init();
APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
NRF_LOG_INFO("SPI example\r\n");
nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
spi_config.ss_pin = SPI_SS_PIN;
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, spi_event_handler, NULL));
while (1)
{
memset(m_rx_buf, 0, m_length);
memset(m_tx_buf, 0, m_length);
m_tx_buf[0] = 0x0b;
m_tx_buf[1] = 0x02;
spi_xfer_done = false;
APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, 3, m_rx_buf, 3));
while (!spi_xfer_done)
{
__WFE();
}
NRF_LOG_INFO("%x\r\n", m_rx_buf[2]);
NRF_LOG_FLUSH();
bsp_board_led_invert(BSP_BOARD_LED_0);
nrf_delay_ms(200);
}
in the beginning, i received nothing but 0x00. then according to nRF52832- why when using nrf_drv_spi with an ADXL362 I need to set the clock in high drive (H0H1)and nrf52 recieves wrong SPI memory flash ID ,i tried to change CLK pin to NRF_GPIO_PIN_H0H1.but no effect.then i changed MISO pin to NRF_GPIO_PIN_PULLUP,i could receive a data of 0xf3,but not 0xf2 according to ADXL362's datasheet.I also tried other register addr,like 0x00 and 0x01.the data received was also incorrect.then i am confused.has anyone know the reasons?